Open
Description
What happened
Serializing a Map to JSON uses the toString
form of the key, rather than the return value of toJSON
.
It should behave like the idiom of serializing an ES2015 Map with JSON.stringify([...map]);
- where the toJSON
return values are used as keys.
How to reproduce
var obj = {
toString() { return 'hello'; },
toJSON() { return 'world'; }
};
var m = new ImmutableJS.Map();
m = m.set(obj, 'the value');
JSON.stringify(m);
/** output is '{"hello":"the value"}' but should be '{"world":"the value"}' **/
JSON.stringify([...m]);
/** output is '[["world","the value"]]' (correct) **/