How to Use json data and how to use json data
Json data is transmitted at the backend and at the front end. Many website developers are no longer familiar with the data format, however, before that, many people still do not know how to use json data,
{"Name": "01"} is the simplest json data format. After receiving the data at the front-end, we need to process the data. The specific processing method is as follows: var result = eval ("(" + data + ")"); after processing the json data, we can obtain the values and attributes in the data. We can call the values in the data as follows: var nam = result. name; in this way, the value of the attribute name in json is obtained. In addition, there are many json data formats, {"address": [{"www ", "eee", "rrr", "ddd"}], "value": "dddd"}, which is also a form of json data, in this form of json data, we can still obtain the attributes and values in the above method, var result = eval ("(" + data + ")"); var add = result. address; after the address attribute is obtained, we use the loop method to obtain the values, var a, B, c, d; for (var I = 0; I <add. length; I ++) {a = add [I]}, B = result. value; in this way, we can get the value, {"address": [{"name": "sss", "value": "gg "}, {"name": "ddd", "value": "hh"}], "city": "ffff"}, which is also a json data format, in this format, we can also parse the data according to the above syntax, var result = eval ("(" + data + ")"); var a; var add = result. address; for (var I = 0; I <add. length; I ++) {a = add [1]. name; alert (a);} var B = result. city; in this way, we can get the data in json. The explanation may be vague. I hope readers can understand the meaning of the content. Thank you for choosing here.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.