[JS] JSON in javescript

Time:2021-9-28

JSON, JavaScript object notation, is a data exchange format created by Douglas Crockford inspired by the literal representation of JS.
JSON is designed to be a minimalist, lightweight and textual subset of JavaScript. The less consensus is needed to achieve interoperability, the easier it will be to achieve interoperability.

The common JSON in our development is as follows
{
“color”: “red”,
“shape”: “square”,
“age”: 13
}

But in fact, JSON format is not the only one like this.
JSON can be formatted as follows:
1. Pure numbers. For example, 333 is JSON.
2. A string wrapped in double quotation marks, such as “666” is JSON. (the ‘666’ in single quotation marks is not)
3. Boolean value. A separate true or a separate false is JSON.
4. The special character null is JSON. (note that undefined, Nan and infinity are not JSON)
5. Array. (note that undefined, Nan, infinity cannot appear in the array)
6. JSON object. (Note: all keys must be in double quotation marks)

[JS] JSON in javescript
[JS] JSON in javescript
[JS] JSON in javescript
[JS] JSON in javescript
(refer to this website for judgment criteriahttps://jsonlint.com/

In addition, function() {} is not JSON.

Therefore, when using JSON. Parse (JSON. Stringify (obj)), undefined, Nan, infinity and function are ignored.

Synchronize updates to your own language bird
https://www.yuque.com/diracke…

Recommended Today

Collection common API

//Collection common API Collection list = new ArrayList<>(); //1. Adding elements successfully returns true regardless of the return value (here refers to list) list.add(“Java”); list.add(“HTML”); list.add(“HTML”); list.add(“Java”); list.add(“wsl”); System.out.println(list); //2. Clear the elements of the collection //list.clear(); //System.out.println(list); //3. Determine whether the collection is empty or not, return true and vice versa System.out.println(list.isEmpty()); //false //4. […]