Home > Mobile >  Mobile Internet application development
Mobile Internet application development

Time:09-26

POST any data submitted, the return value parsing JSON characters showed as follows: 1 a -, b - 2, the JSON file as shown in figure

CodePudding user response:

You use a JsonObject receiving, then assemble line

CodePudding user response:

 

The import org. Json. JSONException;
The import org. Json. JSONObject;

Private void ParseJson (String jsonStr) {
//jsonStr the return value is a JSON string
Try {
JSONObject JSONObject=new JSONObject (jsonStr);
//according to the key value, key
String s="a -" + jsonObject. Get String (" a ")
+ ", "b" - "+ jsonObject. Get string (" b")
+ "c -" + jsonObject. Get string (" c ")
+ ", d - "+ jsonObject. Get string (" d")
+ ", e - "+ jsonObject. Get string (" e");
The e (" TAG ", s);
} the catch (JSONException e) {
e.printStackTrace();
}
}


CodePudding user response:

Their stitching or replace with
 
JSONObject json=new JSONObject (jsonStr);
String s=json. Replace (" {", "")
Replace ("} ", "")
ReplaceAll (" \ ""," ")
ReplaceAll (" : ", "-");
The e (" TAG ", s);
  • Related