How to analyze Json value in iPhone?

Possible duplicate:
How to parse a JSON object in the iPhone SDK (XCode) using the JSON-Framework

I am working in an iPhone application using the JSON structure to parse the Json value from the web service, How to get the Json value as 1221, 1278,3456, ........... etc. (This value is not constant, it dynamically changes the value automatically, so I did not know this) Can this be done?

Thanks at Advance

JSON answer 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
                }
            }
        },
+5
source share
1 answer

Just convert the JSON data to an object

NSData *jsonData = //response data

NSDictionary *object = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];

Then there is no parsing, you are just dealing with a dictionary. (Or an array, etc.)

To get the list you want, you can do ...

NSArray *requiredValues = [object allKeys];
+2
source

All Articles