Home > Database > SQL > body text

what is json

silencement
Release: 2019-06-17 15:20:37
Original
12906 people have browsed it

what is json

#What is json?

JSON (JavaScript Object Notation) is a lightweight data exchange format that is easy to read and write, as well as easy for machines to parse and generate. .

The structure of JSON is based on the following two points

1. A collection of "name/value" pairs. In different languages, it is understood as an object (object), a record (record), a structure (struct) ), dictionary, hash table, keyed list, etc.

2. An ordered list of values ​​is understood as an array in most languages

JSON usage:

JSON represents JavaScript objects in a specific string form. If you assign a string with such a form to any JavaScript variable, then the variable will become an object reference, and this object is constructed from the string. It seems a bit confusing, so we will use an example to illustrate.

Assume here that we need to create a User object with the following attributes

User ID

User Name

User Email

You You can use the following JSON form to represent the User object:

{"UserID":11, "Name":"Truly", "Email":"zhuleipro◎hotmail.com"};
Copy after login

Then if you assign this string to a JavaScript variable, you can directly use any property of the object.

Full code:

<script>

     var User = {&quot;UserID&quot;:11, &quot;Name&quot;:&quot;Truly&quot;, &quot;Email&quot;:&quot;zhuleipro◎hotmail.com&quot;};
     alert(User.Name);
    </script>
Copy after login

The above is the detailed content of what is json. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!