ecmascript-immutable-data-structures icon indicating copy to clipboard operation
ecmascript-immutable-data-structures copied to clipboard

New JSON method

Open nmn opened this issue 9 years ago • 0 comments

There already seems to be a toJSON method on the prototypes of the immutable types.

There should be a new method of JSON as well.

JSON.parseImmutable

This would return an immutable values instead of a mutable one.

In case the toImmutable method is added to the prototypes, this would as simple as this, behind the scenes:

JSON.parseImmutable = (string) => JSON.parse(string).toImmutable()

The actual implementation will be smarter in that it will not throw an error if the JSON value is already immutable (string/number/bool).

nmn avatar Apr 08 '15 16:04 nmn