A question about double quotation marks in Java JSON parsing, javajson
Parse a json data:
{"Manifest": {Version: "3.0 "}}
If you look at it carefully, this string is not in the regular json format. if the Version is missing double quotation marks, it should be:
{"Manifest": {"Version": "3.0 "}}
If you use
JSONObject mainfestObject. getJSONObject ("manifest ");
This method will cause an error, but if you use
String mainfestStr = object. optString ("manifest ","");
JSONObject mainfestObject = new JSONObject (mainfestStr );
The above method is successfully parsed!
Java: What should I do if I want to parse JSON but encounter many double quotation marks?
Json parsing has many ready-made
Json-lib
Gson
Do you want to build your own tires?
The regular expression is used to parse JSON objects, and double quotation marks are processed.
Not much nonsense
Directly Add code
Json does not
Js Code
A = '"Vietnam bans Chinese stamps and indicates that the printed Xisha Islands are" Vietnamese territory ""'; var B; B =. replace (/"Vietnamese territory"/, '\ "Vietnamese territory \"'); document. write (B );