質問

I have an NSString that looks like:

{
   "name": "anEvent",
      "args": [
      {
        "ct": "Un",
        "someUUID": "D7EC06DE-98D3-436F-A657-FB043567FB67",
        "userName": "Joe Smith",
        "long": "-139.724302",
        "lat": "39.402768"
    }
  ]
}

How can I get just the inner part

{
    "ct": "Un",
    "someUUID": "D7EC06DE-98D3-436F-A657-FB04383CFB67",
    "userName": "Joe Smith",
    "long": "-139.724305",
    "lat": "39.402768"
}

into an NSDictionary?

Thanks.

役に立ちましたか?

解決 2

Try with this code:

 NSDictionary *dictObj = [NSJSONSerialization JSONObjectWithData:[yourString dataUsingEncoding:NSUTF8StringEncoding]
                                                         options:NSJSONReadingMutableContainers
                                                           error:nil];
 NSDictionary *requiredObject = [[dictObj objectForKey:@"args"] objectAtIndex:0];

他のヒント

Deserialise the whole string, then use objectForKey:@"args" to drill in to the part you want.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top