title: Keeping the order of NSDictionary keys when converted to NSData with [NSJSONSerialization dataWithJSONObject:]
body: <p>I have the following situation:</p>
  
  <pre><code>NSDictionary *params = @{
      @"Checkout" : @{
          @"conditions" : @{@"Checkout.user_id" : @1},
          @"order" : @{@"Checkout.id" : @"DESC"}
      },
      @"PaymentState" : @[],
      @"Offer" : @[]
  };
  </code></pre>
  
  <p>This dictionary contains params for a webservice request passing a JSON string with the webservice URL. I get the JSON string using NSJSONSerialization class, like this:</p>
  
  <pre><code>NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:nil];
  NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  </code></pre>
  
  <p>The problem is: jsonString "keys" is ordered differently from the original params dictionary keys order, like this:</p>
  
  <pre><code>{
  "Offer":[],
  "PaymentState":[],
  "Checkout":{
      "conditions":{"Checkout.user_id":6},
      "order":{"Checkout.id":"DESC"}
  }
  </code></pre>
  
  <p>}</p>
  
  <p>That is, the "PaymentState" and "Offer" keys come first in jsonString, and i need maintain
  the original order. This is very important, like this:</p>
  
  <pre><code>{
  "Checkout":{
      "conditions":{"Checkout.user_id":6},
      "order":{"Checkout.id":"DESC"}
  },
  "Offer":[],
  "PaymentState":[]
  </code></pre>
  
  <p>}</p>
  
  <p>So guys, how can i do that??</p>