The JSON.stringify()
method converts a JavaScript value to a JSON
console.log(JSON.stringify('a'));
//produce "a"
console.log(JSON.stringify(1));
//produce 1
console.log(JSON.stringify(true));
//produce true
but according to the definition these are not JSON
"a"
1
true
JSON definition is showing below
JSON is built on two structures:
A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
my question is JSON.stringify()
not producing JSON when input above values why is that ?