Compare Revisions

JSON.stringify()

Change Revisions

Revision 628541:

Revision 628541 by ziyunfei on

Revision 628547:

Revision 628547 by ziyunfei on

Title:
JSON.stringify()
JSON.stringify()
Slug:
Web/JavaScript/Reference/Global_Objects/JSON/stringify
Web/JavaScript/Reference/Global_Objects/JSON/stringify
Tags:
"Method", "stringify", "JSON", "JavaScript"
"Method", "stringify", "JSON", "JavaScript"
Content:

Revision 628541
Revision 628547
n61JSON.stringify({});                  // '{}'n61JSON.stringify({});                        // '{}'
62JSON.stringify(true);                // 'true'62JSON.stringify(true);                      // 'true'
63JSON.stringify("foo");               // '"foo"'63JSON.stringify("foo");                     // '"foo"'
64JSON.stringify([1, "false", false]); // '[1,"false",false]'64JSON.stringify([1, "false", false]);       // '[1,"false",false]'
65JSON.stringify({ x: 5 });            // '{"x":5}'65JSON.stringify({ x: 5 });                  // '{"x":5}'
66JSON.stringify({x: 5, y: 6});        // '{"x":5,"y":6}' or '{"y":66JSON.stringify({x: 5, y: 6});              // '{"x":5,"y":6}' or 
>6,"x":5}'>'{"y":6,"x":5}'
67JSON.stringify([new Number(1), new String("false"), new Boolean(f
 >alse)]); // '[1,"false",false]'
68JSON.stringify({x: undefined, y: Object}); // '{}'
69JSON.stringify([undefined, Object])        // '[null,null]'
tt104JSON.stringify(obj);      // '"bar"'
101var json = JSON.stringify({x: obj}); // <code>'{"x":"bar"}'</code105JSON.stringify({x: obj}); // '{"x":"bar"}'
>>. 

Back to History