toJSON()

Creates a JSON-formatted string from an iteratable object.

Syntax

Return Value

A JSON-formatted string.

Examples

var data = {
    a: 1,
    b: 2,
    c: [3, 4, 5],
    d: {
        e: 6,
        f: "foo",
        g: [7, 8]
    }
};
var s = $from(data).toJSON();

document.writeln(s);

/*
This code produces the following output:

{"a": 1, "b": 2, "c": [3, 4, 5], "d": {"e": 6, "f": "foo", "g": [7, 8]}}
*/

Last edited May 18, 2012 at 10:46 AM by suckgamoni, version 1

Comments

No comments yet.