============ Problem Description ============
{
"Address": "cn|\u5e7f\u4e1c|\u6df1\u5733| none| Unicom| none| None ",
"Content": {
"Address": "\u5e7f\u4e1c\u7701\u6df1\u5733\u5e02",
"Address_detail": {
"City": "\u6df1\u5733\u5e02",
"City_code": 340,
"District": "",
"Province": "\u5e7f\u4e1c\u7701",
"Street": "",
"Street_number": ""
},
"Point": {
"X": "114.02597366",
"Y": "22.54605355"
}
},
"Status": 0
}
============ Solution 1============
Use Android-provided jsonarray data = new Jsonarray (your string), and then traverse the data to jsonobject Jsonobject = Jsonarray.getjsonobject (i); Gets the value int adkind = jsonobject.getint (field name) based on the field;
============ Solution 2============
Try {jsonobject jo = new jsonobject (JSON); Int status = jo.optint (" Status "); String address = jo.optstring ("Address"); Jsonobject jo_point = jo.optjsonobject ("point"); String x = jo_point.optstring ("X"); String y = jo_point.optstring ("Y"); Jsonobject jo_content = jo.optjsonobject ("content"); String content_address = jo_content.optstring ("Address"); Jsonobject jo_detail = jo_content.optjsonobject ("Address_detail"); String city = jo_detail.optstring ("City"); Int code = jo_detail.optint ("City_code "); String district = jo_detail.optstring ("District"); String province = jo_detail.optstring ("province"); String street = jo_detail.optstring ("Street"); String street_number = jo_detail.optstring ("Street_number");} catch (jsonexception e) {e.printstacktrace ();}
============ Solution 3============
[
Reference 3 Floor wlianghe00 's reply:
try {jsonobject Jo = new Jsonobject (JSON); int status = Jo.optint ("status"); String address = jo.optstring ("Address");Jsonobject jo_point = Jo.optjsonobject ("point"); Jo changed to Jo_content.String x = jo_point.optstring ("x"); String y = jo_point.optstring ("y"); Jsonobject jo_content = jo.optjsonobject ("content"); String content_address = jo_content.optstring ("Address"); Jsonobject Jo_detail = Jo_content.optjsonobject ("Address_detail"); String City = jo_detail.optstring ("city"); int code = jo_detail.optint ("City_code"); String district = jo_detail.optstring ("district"); String province = jo_detail.optstring ("province"); String Street = jo_detail.optstring ("Street"); String Street_number = jo_detail.optstring ("Street_number");} catch (Jsonexception e) {e.printstacktrace ();}
============ Solution 4============
Such a standard format, with Jsonobject
The great God helps Java parse JSON