class method Object.toJSON
Object.toJSON(object) → String
-
object(Object) – The object to be serialized.
Returns a JSON string.
undefined and function types have no JSON representation. boolean
and null are coerced to strings.
For other types, Object.toJSON looks for a toJSON method on object.
If there is one, it is used; otherwise the object is treated like a
generic Object.
For more information on Prototype's JSON encoder, hop to our tutorial.
Example
var data = {name: 'Violet', occupation: 'character', age: 25, pets: ['frog', 'rabbit']};
Object.toJSON(data);
//-> '{"name": "Violet", "occupation": "character", "age": 25, "pets": ["frog","rabbit"]}'