ios - json数组解析失败
怪我咯
怪我咯 2017-04-17 13:34:57
0
2
249
[{"vehicleNum":"\u9c81Q24956","shipDtPlan":Wed Jan 14 14:15:00 CST 2015,"orderCode":"20150117104","originAddress":"345","consigneeTelphone":"","goodsQuantity":234,"consigneePhoneNum":"","userName":"","limitHours":62,"goodsWeight":234,"goodsUnit":"234","driverName":"\u5f20\u4e09","orderId":104,"createDt":Sat Jan 17 00:00:00 CST 2015,"customerName":"3\u989d\u5934\u513f\u7ae5","overdueDt":Tue Jan 20 04:15:44 CST 2015,"consigneeName":"","customerPhoneNum":"13000000001","collPayRemark":"","customerCompany":"345","transactor":"","sendTime":Thu Jan 15 00:00:00 CST 2015,"origin":"345                                               ","orderStatus":2,"deliveryReamrk":"","destination":"","consigneeCompany":"","driverPhoneNum":"13511111111","destinationAddress":"","arriveDtPlan":Sat Jan 17 00:00:00 CST 2015,"goodsName":"rwerw"},


{"vehicleNum":"\u9c81Q24956","shipDtPlan":Wed Jan 14 13:25:00 CST 2015,"orderCode":"20150115105","originAddress":"345","consigneeTelphone":"","consigneePhoneNum":"","goodsWeight":234,"goodsUnit":"234","driverName":"\u5f20\u4e09","orderId":105,"createDt":Thu Jan 15 13:25:25 CST 2015,"customerName":"3\u989d\u5934\u513f\u7ae5","consigneeName":"","customerPhoneNum":"13000000001","collPayRemark":"","customerCompany":"345","transactor":"","origin":"345                                               ","orderStatus":1,"destination":"","consigneeCompany":"","deliveryReamrk":"","driverPhoneNum":"13511111111","destinationAddress":"","goodsName":"234234"}]

返回的json是nsstring格式的,用asi接收有乱码,但是用

NSArray *arrlist=[strJson objectFromJSONString];

返回的是null,转换成data 用

ret = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];

也不能转换成数组,本人较菜,望大神不吝赐教。

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
伊谢尔伦

Your JSON data is wrong, so it cannot be converted. This question has nothing to do with OC

JSONThe form "shipDtPlan":Wed Jan 14 14:15:00 CST 2015 is not supported. Date should be converted to timestamp even string type is ok

JSON value can be:

  • Number (integer or floating point)
  • String (in double quotes)
  • Logical value (true or false)
  • Array (in square brackets)
  • Object (in curly braces)
  • null

Reference: http://www.w3school.com.cn/json/json_syntax.asp

PHPzhong

You need jsonlint
http://jsonlint.com/

First convert to NSDictionary or NSArray, and then convert the object.
That string can be converted into an NSDate object.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!