json.stringify ()
The Json.stringify () method is converts a JavaScript value to a JSON string, optionally replacing values if a replacer functi On is specified, or optionally including only the specified properties if a replacer array is specified. Syntax
Json.stringify (value[, replacer[, space])
Parameters Value the value to convert to a JSON string. replacer Optional A function that alters the behavior of the stringification process, or A array of string&nb sp;and numberobjects that serve as a whitelist for selecting/filtering the properties of the "the" value object to be incl Uded in the json string. If This value is null or not provided, all properties of the object are included the resulting json string. space Optional a string or number object that ' s used to inserts white spaces into the output JSO N string for readability purposes. If It is a number, it indicates the number of the ' space characters to ' as white spaces; This is capped at (if it is greater, the value is just 10). Values less than 1 indicate that no spaces should be used. If it is a string, the string (or the characters of the string, if it's longer than that) is used as Whit E space. If This parameter isn't provided (or is null), no White are used.
return value
A JSON string representing the given value. Description
Json.stringify () converts a value to JSON notation representing it:properties of Non-array-objects are not Guara Nteed to is stringified in any particular order. Don't rely on ordering of properties within the same object within the stringification. Boolean, number, and string objects are converted to the corresponding primitive values during Stringification, in accord with the traditional conversion semantics. If undefined, a function, or a symbol is encountered during conversion it are either omitted (when it's found in a O bject) or censored to null (when it's found in an array). json.stringify can also just Return un Defined when passing in "pure" values like json.stringify (function () {}) or json.stringify (undefined). All symbol-keyed properties is completely ignored, even when using the replacer function. Non-enumerable properties would be ignored
json.stringify ({}); ' {} ' json.stringify (true); ' True ' json.stringify (' foo '); ' foo ' ' Json.stringify ([1, ' false ', false]); ' [1, ' false ', false] ' json.stringify ({x:5}); ' {' X ': 5} ' json.stringify (New Date (2006, 0, 2, 4, 5))//' "2006-01-02t15:04:05.000z" ' Json.stringify ({x:5, y:6
});
' {' X ': 5, ' Y ': 6} ' or ' {' Y ': 6, ' X ': 5} ' json.stringify ([New Number (1), New String (' false '), new Boolean (false)]);
' [1, ' false ', false] ' json.stringify ({x: [ten, Undefined, function () {}, Symbol (')]};
' {' x ': [10,null,null,null]} '//Symbols:JSON.stringify ({x:undefined, y:object, Z:symbol (')}); ' {} ' json.stringify ({[Symbol (' foo ')]: ' foo '}