取data中id的值如下:
String demo = "{
"errno": 0,
"errmsg": "",
"data": {
"id": "2345",
"name": "测试",
"ocode": "165",
"pro_id": 3195,
"city_id": 3196,
"district_id": 3205,
"created_at": "2019-06-27 10:53:44",
"updated_at": "2019-06-27 10:53:44"
}
}";
JSONObject obj= (JSONObject) JSON.parse(demo );//将字符串转为json对象
JSONObject dataobj= (JSONObject) obj.get("data");//取得data的值
Object data = dataobj.get("id"); // 从data中取id的值