Skip to main content

JSON.stringify

Certain objects (like Maps) can't be stringified directly - you'll get an empty object as the result, as they don't have any properties. Example:

let map = new Map();
map.set("key1", "value1");

// '{}'
JSON.stringify(map);

// '[["key1","value1"]]'
JSON.stringify(Array.from(map.entries()));