0

How to get id from this responce in ios

{
     "kind": "coordinate#jobList",
      "nextPageToken": "1339008280772001",
      "items": [
      {
        "kind": "coordinate#job",      // Job #1
        "id": "2502",
        "state": {
        "kind": "coordinate#jobState",
        "assignee": "mike@example.com",
        "location": {
          "kind": "coordinate#location",
          "lat": 37.421991,
          "lng": -122.08393,
         "addressLine": [
          "1600 Amphitheatre Pkwy, Mountain View CA 94043"
        ]
      },
    "note": [
     "Watch out for androids AND the Tyrannosaurus rex."
    ],
    "title": "Service call",
    "customerName": "Google",
    "customerPhoneNumber": "1-650-253-0000"
   },  
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
bhumi
  • 57
  • 1
  • 8

1 Answers1

-1

Use NSJSONSerialization as suggested
Your provided JSON is not proper so write a sample code

/*
Json structure
{
"AD":"Andorra",
"AE":"United Arab Emirates"
}
*/
 NSString *myStr = @"{\"AD\": \"Andorra\", \"AE\": \"United Arab Emirates\"}";
 NSData* cData = [myStr dataUsingEncoding:NSUTF8StringEncoding];

 NSDictionary *JSONDictionary = [NSJSONSerialization JSONObjectWithData:cData
                                 options:0
                                 rror:NULL];

 NSString *myData = [JSONDictionary objectForKey:@"AD"];

Here in myData you will get Andorra

Jageen
  • 6,345
  • 2
  • 37
  • 56
  • with respect to the rules of stackoverflow should i have to remove my answer ?? which accepted by OP but some people thought its unusefull – Jageen Dec 13 '14 at 06:49