Home >Database >SQL >what is json

what is json

silencement
silencementOriginal
2019-06-10 13:16:2412976browse

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"};

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>

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

Statement:
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

Related articles

See more