Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

b0yax

macrumors newbie
Original poster
Feb 24, 2010
6
0
Hi,

I've got here a sample JSON response:
{
1 = {
"name" = John Depp;
"category" = Animals;
"descripton" = "Some texts1";
"id" = 1;
};
2 = {
"name" = Shi;
"category" = Animals;
"description" = "some texts2";
"id" = 2;
};
3 = {
"name" = Sha;
"category" = Animals;
"description" = "some text3";
"id" = 3;
};
}

How I could convert this from NSDictionary to NSArray so I can populate the data objects into the table view?

Need advise. Thanks
 
Get the keys as a sorted array, then enumerate the ordered keys. See the reference doc for NSDictionary, and look for methods that return sorted keys in an NSArray.

Or just use the resulting sorted array directly, and retrieve objects by key. That is, a composition consisting of an array of sorted keys accessible by index, and the resulting key is then used to retrieve the value held in the dictionary.

BTW, your JSON text is malformed: '=' instead of ':', missing some quotes, and contains semicolons, which JSON doesn't use. What you posted looks more like an old-style plist, but if so, that's malformed, too: missing some quotes.

http://json.org/
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.