无法序列化NSData目标C.

时间:2014-08-01 03:15:53

标签: ios objective-c json

我无法序列化以下JSON数据。我看不出有什么不妥。

[{"id":2182,"title":"HEAVEN ON EARTH","content":"Description","post_date":"2014-07-28 09:29:45","post_modified":"2014-07-28 09:29:45","abc_featured":"","abc_rating":"0","abc_recommended":"","abc_phone":"","abc_address":"","abc_address2":"","abc_postcode":"","abc_suburb":"","abc_state":"NSW","abc_website":"http:\/\/","abc_email":"Pralead@hotmail.com","abc_lat":"-1000","abc_lon":"10000","abc_closed_txt":"","yes_event":"","from_event_date":"","to_event_date":"","abc_location":"","abc_age":"","abc_cost":"","abc_prebook":"","abc_parentaccompany":"","abc_changingfaciltiy":"","abc_playarea":"","abc_pramaccessibility":"","abc_breastfeedingarea":"","abc_refreshments":"","abc_inoutdoor":"","abc_parking":"","abc_freetrail":"","feature_name":null,"feature_value":null,"feature_available":[],"image1":"http:\/\/localhost\/wordpress\/wp-content\/uploads\/2014\/07\/IMG_0014.png","image2":"http:\/\/localhost\/wordpress\/wp-content\/uploads\/2014\/07\/IMG_0011.png","image3":"http:\/\/localhost\/wordpress\/wp-content\/uploads\/2014\/07\/IMG_0009.png","Monday_from_time":"","Monday_to_time":"","Tuesday_from_time":"","Tuesday_to_time":"","Wednesday_from_time":"","Wednesday_to_time":"","Thursday_from_time":"","Thursday_to_time":"","Friday_from_time":"","Friday_to_time":"","Saturday_from_time":"","Saturday_to_time":"","Sunday_from_time":"","Sunday_to_time":""}]

SERIALIZE的代码是:

NSArray *jsonArray=[NSJSONSerialization JSONObjectWithData:_downloadedData options:NSJSONReadingAllowFragments error:&error];

_downloadedData是我从JSON API获取的数据。 我可以通过NSLOG看到数据。

1 个答案:

答案 0 :(得分:0)

问题中的JSON至少存在问题,主要问题是" null"用于字典项的值。 例如:" feature_name":null。

NSDictionary值必须是对象。

问题中的JSON是NSLog()的{​​{1}}吗?