首页 > 学院 > 开发设计 > 正文

Json解析

2019-11-06 09:38:17
字体:
来源:转载
供稿:网友

自己手动解析:

 {"body" :   {"mobile":"13714664734","email":"","icon":"","open_id":"f5994ced6530405ebc07f8fecd1beb12","country_code":"86","user_name":"13714664734","is_update_name":"0"},

"code":"0","msg":"成功"}

{}:是对象--->sonObject = new JSONObject(response);jsonBody = jsonObject.optJSONObject("body");String mobile= jsonBody .optString("mobile");{   "body":    {      "PRoducts": [      {         "describe": "无流量限制",         "type": 1,    //产品类型(0:虚拟 1:实际)         "      }],      "coupons": [      {         "name": "折扣券",     //优惠券名称         "describe": "",    //优惠券描述      }],      "amount": 12.11,  //订单总金额      "order_num": "12000100", //订单流水号       },   "code": "0",   "msg": "成功"}

[]:是集合 :

JSONArray jsonArrayProList = jsonBody.optJSONArray("products");

jsonArrayProList  是集合,定义循环,解析多个products.

JSONObject jsonObjectOne = jsonArrayProList.optJSONObject(i);String     describe      = jsonObjectOne.optString("describe");


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表