The content of this article is about the implementation of json front-end and back-end data interaction methods. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Official JSON introduction WIKI Encyclopedia. JavaScript object notation.
JSON: JSON data has two forms, one is an unordered collection of key-value pairs (object), and the other is an ordered collection of values (array).
{string : value, ...} object
{ "birthday": "1996-1-1", "name": "王小二", "comment": "这是注释", "major": [ "Information", "Math" ], "has_girlFriend": false, "age": 22 }
[value, ...] array
[{ "birthday": "1996-1-1", "name": "王小二", "comment": "这是注释", "major": [ "Information", "Math" ], "has_girlFriend": false, "age": 22 }, { "birthday": "1997-1-1" }, "name", "age" ]
There are 7 value forms of value:
object, array
number, string, (true, false), null
JSON-java
class libraryin In java, operations on JSON data.
Mainly the use of the JSONObject class, there are multiple ways to generate JSONObject objects:
Directly generate new JSONObject objects, and put key-value through the put method.
Generate objects by constructing a Map object, putting key-value in through the put method, and then passing in the constructor of the JSONObject object.
Generate objects by constructing a Bean object and then passing in the constructor of the JSONObject object.
Read the text file of JSON data through IO, read the data as a String string, and then pass it into the constructor of the JSONObject object to generate the object.
The above is the detailed content of Implementation of json front-end and back-end data interaction methods. For more information, please follow other related articles on the PHP Chinese website!