2012-08-13 27 views
0

我创建的应该看起来像一个JSON字符串:JSON出来向后NSJSONSerializaton

{ "request_type":"send_string", "security_level":0, "device_type":"ios", "blob":{"string":"blah"}"} 

这是我做过什么:

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]; 

当我打印出来带的NSLog,我得到

{"security_level":"0","request_type":"send_string","device_type":"ios","blob":{"string":"hello"}} 

它出现失序...什么给了?

回答

5

词典不按其性质排序。你不能指望这种行为。

0

默认情况下,词典是按照其键(按字母顺序)排序的。