How to Use json data and how to use json data

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.