将JSON串转化为字典或者数组

- (id)toArrayOrNSDictionary:(NSData *)jsonData{

    NSError *error = nil;

    id jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData

                                                    options:NSJSONReadingAllowFragments

                                                      error:&error];

    

    if (jsonObject != nil && error == nil){

        return jsonObject;

    }else{

        // 解析错误

         return nil;

    }

}

猜你喜欢

转载自my.oschina.net/fllKevin/blog/1806093