This week, for work reasons, I began to contact json, a language mainly used for data exchange. In general, the format of json is simpler than xml, at least it seems that there are few rules. xml is often used to create rules due to scalability, so it is quite troublesome. Different from json, the key-value pairs, arrays, and conversion of Simple objects and strings make it very suitable for data exchange. 1. There are two structures defined in JSON: object and array 1. An object starts with "{" (left parenthesis) and ends with "}" (right Parenthesis. Each "name" is followed by a ":" (colon); "," (comma) is used to separate the "name/value" pairs. The name is enclosed in quotation marks. If the value is a string, it must be enclosed in parentheses, but not numeric. For example: var object = {"name": "lxy", "age": 22, "birthday": "19910102"}; 2. an array is an ordered set of values. An array starts with "[" (left square brackets) and ends with "]" (right square brackets. Values are separated by commas. Ii. Conversion 1. json String -- JSONObject object -- String jsonMessage = "{\" \ ": \" 88 \ ", \" \": \ "78 \", \ "computer \": \ "99 \"} "; String value1 = null; try {// convert the string to jsonObject JSONObject myJsonObject = new JSONObject (jsonMessage); // obtain the value value1 = myJsonObject. getString ("Mathematics");} catch (JSONException e) {} 2. java object -- JSONObject object -- json string User user = new User (); user. setName ("lxy"); user. setSex (22); JSONObject myJsonObject = JSONObject. fromObject (user); System. out. println (jo2.toString (); var jsonArrStr = [{'name': 'zhang san', 'age': '20'}, {'name': 'Li si ', 'age': '18'}];