json类似如下,一般来说从网络得到的时候是一个nsdictionary,可以把它放到一个nsarray中以保持顺序不变,但是得到那个nsdicationary顺序会和json本身不一样么? 如何解决?
"All Shop" = 500;
dessert = {
All = 172;
Barbeque = 44;
Local = 53;
Sids = 43;
};
drink = {
All = 84;
Cafee = 31;
Juice = 53;
};
fastFood = {
All = 246;
Dumplings = 12;
"Famous Brand" = 128;
Noodes = 27;
"Over Rice" = 115;
"Pot Food" = 24;
};
feature = {
All = 138;
Guangdong = 14;
Muslim = 12;
"Sea Food" = 58;
Sichuan = 37;
"Toast Fish" = 27;
};
foreigner = {
All = 43;
Japan = 13;
Korea = 25;
Spaghetti = 1;
West = 8;
};
}
What you posted is not JSON
Neither JSON nor NSDictonary guarantees that keys are in order
So this is not a problem that needs to be "solved", you just need to not "create" problems by relying on things that are not guaranteed
The order of Dictionary/JSON has nothing to do with the user. You can only use the key to get the Value. What does the order matter?
If you want order, then use an array