I’m creating a JSON String that’s supposed to look like:
{ "request_type":"send_string", "security_level":0, "device_type":"ios", "blob":{"string":"blah"}"}
This is what I did:
NSDictionary *requestData = [NSDictionary dictionaryWithObjectsAndKeys:
@"send_string",@"request_type",
[NSNumber numberWithInt:0],@"security_level",
@"ios",@"device_type",
//No Email Provided, This is just for testing
blobData,@"blob",
nil];
NSData *JSONRequestData = [NSJSONSerialization dataWithJSONObject:requestData options:kNilOptions error:&error];
When I print this out with NSLog, I get
{"security_level":"0","request_type":"send_string","device_type":"ios","blob":{"string":"hello"}}
It comes out of order…what gives?
Dictionaries are not ordered by their nature. You cannot expect this behavior.