JSON数据解析实例

根据接口返回的数据结构:建实体类去接受

根据数据返回的最外层是{ }还是[],如果是大括号用对象去接受,getObject.如果是中括号,则用List集合去接受。

例如:

返回的数据是一个集合:

{

"data": [

        {

"address": "广东茂名电白县",

"categoryName": "有机肥",

"isHonesty": 1,

"isRealName": 2,

"picPath": "http://www.tsxn360.com/uploadFiles/20160904/e0250043fe044a668941796e2e4bd937-marklogo.jpg",

"priceUnit": "/",

"productTitle": "",

"publishUserName": "罗兰旭",

"showPrice": "1500~2500",

"specInfo": "规格:不限",

"supplyId": "472049e788ec4c718e9d26ad0a354f07",

"timeStr": "1月前"

        },

        {

"address": "甘肃陇南徽县",

"categoryName": "百花蜜",

"isHonesty": 1,

"isRealName": 2,

"picPath": "http://www.tsxn360.com/uploadFiles/20160912/c890be981e9c496ab4e2698763da0aae-marklogo.jpg",

"priceUnit": "/",

"productTitle": "深山百花蜜",

"publishUserName": "韩峥伟",

"showPrice": "85~95",

"specInfo": "波美度:41 纯度:纯度:100% 包装规格:1",

"supplyId": "6114e5638382497fab61dc9cf5b705cc",

"timeStr": "1月前"

        }

    ],

"msg": "",

"status": 1

}

List<AdviceBean>mDatas;

mDatas = FJson.getObjects(result.getData().toString(), AdviceBean.class);

返回的数据是一个对象:

 

{

    "dataList": [

        {

            "sellerId": "105665311973",

            "grandTotal": "0.01",

            "timeNum": "2016-10-24 22:12:22",

            "realName": "哈哈",

            "ISHONESTY": 1,

            "logisticsCost": "0.00",

            "saleUserIshonesty": 1,

            "deliveryAddress": "河北石家庄长安区UK",

            "buyerId": "101208908715",

            "payState": 2,

            "unpayTime": "2016-10-25 08:42:07",

            "saleUserIsrealname": 1,

            "co": "北京北京东城区",

            "subtotal": "0.01",

            "priceUnit": "元/斤",

            "supplyId": "3505567d827144538bcc574919c3a72d",

            "logisticsType": 2,

            "qtyUnit": "斤",

            "checkType": "2",

            "supplyAddressId": "246984b92e0341558d7e512502cccfd0",

            "buyUserIshonesty": 1,

            "buyUserEvalCnt": "0",

            "saleUserName": "哈哈",

            "orderQty": 1,

            "categoryId": "",

            "orderId": "83bec301d531487f8d47022e864d43b9",

            "addressId": "6757a3ff62aa421cb495f9827a255ad2",

            "supplyAddress": "北京东城区hahaha",

            "buyUserName": "小航",

            "crtTime": "2016-10-24 22:12",

            "spec": "平均单串重量:0.6~0.8斤",

            "timeOut": "剩余9天",

            "orderNo": "31201610242212228342",

            "sellUserEvalCnt": "0",

            "ISREALNAME": 1,

            "buyUserIsrealname": 1,

            "orderState": 60,

            "orderType": 1,

            "labourCosts": "0.00",

            "categoryName": "青提",

            "unitPrice": 0.01,

            "supplyPic": "http://test.tsxn360.com/uploadFiles/20161021/9530a9e711e744f297d30474ad877138-marklogo.jpeg"

        },

    ],

    "dataCnt": 13,

    "typeList": [],

    "dataInfo": 0,

    "bankCnt": 0

}

OrderListBean order = FJson.getObject(result.getData()
        .toString(), OrderListBean.class);

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhwadezh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值