Possible Duplicate:
How to parsing JSON object in iPhone SDK (XCode) using JSON-Framework
I am working in iPhone application, Using JSON framework to parse Json value from Web service, How to get the Json value like 1221, 1278,3456,........... etc. (This value are not constant, it is dynamically change the value automatically, so i didn't know that) Is it possible to do that?
Thanks in Advance
JSON Response for your reference:
{
"1221":
{
"type": "product",
"product_id": 1221,
"intID": "1",
"name": "rer Margherita",
"des": "Tomatensauce, Käse<sup>1</sup>",
"img": "",
"isDeal": false,
"cat": {
"1": {
"price": 4,
"pos": 1,
"catname": "normal",
"extras": false
},
"2": {
"price": 5.9,
"pos": 2,
"catname": "groß",
"extras": false
}
}
},
"1278": {
"type": "product",
"product_id": 1222,
"intID": "2",
"name": "ere Zwirerebeln",
"des": "er",
"img": "",
"isDeal": false,
"cat": {
"1": {
"price": 2,
"pos": 1,
"catname": "rer",
"extras": true
},
"2": {
"price": 6.2,
"pos": 2,
"catname": "mega",
"extras": true
}
}
},
Just convert your JSON Data into an object
NSData *jsonData = //response data
NSDictionary *object = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
Then there is no parsing involved, you just deal with the dictionary. (Or array, etc...)
To get the list you want you can then do...
NSArray *requiredValues = [object allKeys];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With