JSON NSDictionary disordered after AFJSONResponseSerializer JSON NSDictionary disordered after AFJSONResponseSerializer json json

JSON NSDictionary disordered after AFJSONResponseSerializer


NSDictionary in Cocoa does not keep order of elements. So using AFJSONResponseSerializer it is impossible to keep the keys in the same order they are in JSON file. You have to parse JSON yourself or change JSON structure to use NSArray.

For example:

{    [        {"name" : "first key", "value" : [val1, val2, val3]},        {"name" : "second key", "value" : [val1, val2, val3]},        {"name" : "third key", "value" : [val1, val2, val3]},        {"name" : "fourth key", "value" : [val1, val2, val3]}     ]}

UPDATE:

This thread could be useful for you Keeping the order of NSDictionary keys when converted to NSData with [NSJSONSerialization dataWithJSONObject:]