JSON conversion method resolution

Difference JSON.parse () and JSON.stringify () of

JSON.parse (): is parsed object from a string json

JSON.stringify (): parse the character string from an object

 

json_encode (): name suggests json encoded array or an object is encoded as the string function json

json_decode (): On the contrary, the string is converted into an array or json objects

 

Syntax: 
JSON.stringify (value [, the replacer] [, Space]) 
value: must be in the field. Is the object you enter, such as arrays, ah, ah, and so kind. 
replacer: This is optional. It is divided into two ways, one is the method, the second array. 
Case 1: Let's say that data, through the following experiments we can know, and it is the first between the two. In general, the results of our series is carried out by key-value pairs expressed. 
For example: 
name: "LAN", Age: 25 
this form. 
So, if this form of words, if the second value in the presence of the first, then second, then on to the value of doing key, the first value is value be said that if there is no, sorry, ignored. [Is a bit abstract, I think so too, but you wait to see experiments on OK. . Whirring.
Case 2: If it is a method, it is very simple, that is to say to each object after serialization (remember every) pass into the inside processing method. 
space: a good understanding of what to do with the separator. 
1. If omitted, then the value displayed no delimiter. Direct output to 
2. If it is a number, then it is defined indented few characters, of course, if more than 10, the maximum value of 10. 
3. If the escape character is a number, such as "\ t", denotes carriage then it per line Enter. 
4. If only string, OK, on the line when the output value of each of these additional strings up on OK. Of course, the maximum length is 10 characters.

Guess you like

Origin www.cnblogs.com/GME-qiyueliu/p/11453399.html