开发者

how to avoid sorting while parsing json data in iphone sdk

I am parsing the json data in iphone sdk, but the problem is after i开发者_运维知识库 parsed it i am getting the data in sorted order based on the alphabetic. when i see the json structure in json online viwer i am getting the objects correctly something like Physician name: Designation: Adress: Fax:

but after i parsed the json data in iphone i am getting some thing like this

Adress: Designation: Fax: PhysicianName:

how to avoid the sorting while parsing the json in iphone.


Order in Json object is unspecified and is application dependent. If your values are ordered you have to put them in a list.

http://www.ietf.org/rfc/rfc4627.txt

The RFC only specify that key should be unique.

Your question is a duplicate from : JSON order mixed up

  • Why do you need to keep the order ?
  • Do you have any control of the data coming from the server ?


I guess you use a NSDictionary to parse the data into. And i guess NSDictionary sorts them based on keys. why do you want to worry about order if you are going to access it based on keys.

UPDATE

allValues

Returns a new array containing the dictionary’s values.

- (NSArray *)allValues

Return Value

A new array containing the dictionary’s values, or an empty array if the dictionary has no entries.

Discussion

The order of the values in the array isn’t defined.

It clearly states the order is not defined. So i guess its better to use the dictionary as such and use the keys to load your table

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜