-7

How to parse JSON which consist of array of array objects?

Here is my JSON string:

I want to parse Delhi,uttar pradesh,south mumbai,karnataka,test in one array and then llly central delhi,Ghaziabad.. to another set of array?

{
  "Result": "Success",
  "RegionList": [
    {
      "Delhi": {
        "Central Delhi": [
          "Dwarka Nagar"
        ]
      },
      "Uttar Pradesh": {
        "Ghaziabad": [
          "Kalka Garhi Chowk"
        ]
      },
      "South Mumbai": {
        "Mumbai": [
          "Navi Mumbai"
        ]
      },
      "Karnataka": {
        "bangalore": [
          "Silk board"
        ]
      },
      "test": {
        "test": [
          "testtyt"
        ]
      }
    }
  ]
}
Konamiman
  • 49,681
  • 17
  • 108
  • 138
muthukumaresh
  • 103
  • 1
  • 8

1 Answers1

3

You should use

NSJSONSerialization

It will automatically take care of parsing and will return you a dictionary of array objects. The objects within the Dictionary can be accessed using key value pair.

NSDictionary* json = [NSJSONSerialization
                      JSONObjectWithData:yourjsonData
                      options:kNilOptions
                      error:&error];
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Deepesh Gairola
  • 1,252
  • 12
  • 18