Decode JSON to NSArray or NSDictionary

前端 未结 5 1637
野的像风
野的像风 2020-11-29 09:51

I hope to decode the JSON data below:

{
    \"content\":
    [   
        {
            \"1\":\"a\",
            \"2\":\"b\",
            \"3\":\"c\",
               


        
5条回答
  •  孤街浪徒
    2020-11-29 10:07

    You can do the following:

    NSData *data = ...; //JSON data
    NSError *jsonError = nil;
    [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
    

    You will get back an NSDictionary containing an NSArray containing a single NSDictionary containing five NSString objects.

提交回复
热议问题