开发者

JSON Parse objective c

开发者 https://www.devze.com 2023-03-03 19:27 出处:网络
I´ve got the next json code: { \"person_1\":{ \"name\" :\"person\", \"pictures\":[ {\"images\":{ \"picture_1\": \"url1\",

I´ve got the next json code:

{

"person_1":{
      "name" :"person",
      "pictures":[ 
                  {"images":{
                             "picture_1": "url1",
                             "picture_2": "url1",
                            }
                  }
               ],
}
}

Can anyb开发者_Go百科ody tell me how to get the element "picture_1"? I am using touchJson for objective c.

Best Regards


First, I would recommend using yajl as I found it very convenient for my work.

NSBundle * personBundle = [[yourstring yajl_JSON] valueForKey:@"person_1"];
NSArray * picturArray = [personBundle valueForKey:"pictures"];
NSBundle * imagesBundle = [picturArray objectAtIndex:0];
NSString * myUrl = [imagesBundle valueForKey:"picture_1"];

This should pretty much do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消