Json.stringify Grammar Explanation

Source: Internet
Author: User

role: This function is mainly for the purpose of serialization objects.
Maybe some people are allergic to the word serialization, my understanding is very simple. This means converting the type of the object to a string type (or, more specifically, the JSON type). It's so simple. For example, you have a class, so you can convert it to the corresponding JSON type by this method. It's simple.
Then look.
Syntax:
Json.stringify (value [, Replacer] [, space])
Value: is the required field. Is the object you have entered, such as array Ah, class AH and so on.
Replacer: This is optional. It is divided into 2 ways, one is method, the second is an array.
begin to illustrate with examples;

<script type= "Text/javascript" src= "./js/customization/json2.js" ></script>
<script language= "JavaScript" >        var t = json.parse (' {"name": 123} ');        alert (t.name);             var student = new Object ();   Student.name = "Lanny";   Student.age = "";   student.location = "China", var ar = new Array (), for (var i = 0; i<8;i++) {  var elelem = new Object ();  elelem.name = ' AA ' +i;  elelem.age = ' BB ' +i;  Ar.push (Elelem);}  Student.par = AR; var json = json.stringify (student);   alert (student);   alert (JSON);  </script>


Json.stringify Grammar Explanation

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.