A, wherein a value acquired based on the return parameter format
1. give ResponseEntity <String> responseEntity Object
import org.springframework.http.ResponseEntity; 得到ResponseEntity<String> responseEntity对象 <200, { "code":0, "data":{ "list":[ { "amount":0, "auditTime":"", "channelType":"", "createTime":"2019-08-13 17:01:55", "creditStatus":"", "edit":true, "fundsStatus":"", "id":372, "idNo":"", "lendRequestId":0, "mobile":"13289989000", "name":"客户姓名", "soinsStatus":"", "state":0, "stateText":"", "viewStateText":0 } ] }, "mask":"251eeedb-e214-47c6-aa0c-3eb6c7b67aa0", "msg":"success", "timestamp":1566089672 } ,{Server=[Tengine/2.1.1], Date=[Sun, 18 Aug 2019 00:54:32 GMT], Content-Type=[application/json;charset=UTF-8], Content-Length=[412], Connection=[keep-alive]}>
The ResponseEntity <String> responseEntity object, retrieving body part, body format string not json
Content responseEntity.getBody = String ();
Content output:
{ "code":0, "data":{ "list":[ { "amount":0, "auditTime":"", "channelType":"", "createTime":"2019-08-13 17:01:55", "creditStatus":"", "edit":true, "fundsStatus":"", "id":372, "idNo":"", "lendRequestId":0, "mobile":"13243345566", "name":"客户姓名", "soinsStatus":"", "state":0, "stateText":"", "viewStateText":0 } ] }, "mask":"251eeedb-e214-47c6-aa0c-3eb6c7b67aa0", "msg":"success", "timestamp":1566089672 }
3. Obtain list of field values id, name, mobile, etc.
3.1 json string objects into json
// the string into json json objects JSONObject json = JSONObject.parseObject (content);
Export
{ "msg":"success", "code":0, "data":{ "list":[ { "amount":0, "soinsStatus":"", "viewStateText":0, "edit":true, "mobile":"12324435555", "channelType":"", "creditStatus":"", "fundsStatus":"", "idNo":"", "auditTime":"", "createTime":"2019-08-13 17:01:55", "stateText":"", "name":"客户姓名", "id":372, "lendRequestId":0, "state":0 } ] }, "mask":"251eeedb-e214-47c6-aa0c-3eb6c7b67aa0", "timestamp":1566089672 }
3.2 data extraction section
// remove the portion of the object data JSONObject data = json.getJSONObject ( "data" );
Export
{ "list":[ { "amount":0, "soinsStatus":"", "viewStateText":0, "edit":true, "mobile":"13234444555", "channelType":"", "creditStatus":"", "fundsStatus":"", "idNo":"", "auditTime":"", "createTime":"2019-08-13 17:01:55", "stateText":"", "name":"客户姓名", "id":372, "lendRequestId":0, "state":0 } ] }
3.3 data array contains the contents of the list with the brackets [], so the object into type JSONArray
// conversion type object JSONArray JSONArray jsonArray = data.getJSONArray ( "list" );
Output;
[ { "amount":0, "soinsStatus":"", "viewStateText":0, "edit":true, "mobile":"13234444555", "channelType":"", "creditStatus":"", "fundsStatus":"", "idNo":"", "auditTime":"", "createTime":"2019-08-13 17:01:55", "stateText":"", "name":"客户姓名", "id":372, "lendRequestId":0, "state":0 } ]
3.4 If it is more arrays
jsonArray.getJSONObject(index)
// Select a random array
JSONObject idInfo = jsonArray.getJSONObject (randomInteger (0 , jsonArray.size ()));
String id=idInfo.getString("id");