Should JSON.parseImmutable take a reviver function, and if so, what should its behavior be?
Assuming there is a reviver function: It seems straightforward that in cases where the reviver returns either a primitive or the same object it was passed, that it should behave just like the reviver in JSON.parse. What's less obvious is what do if the reviver returns an object other than the object it was passed. Is it accepted without condition? Does the engine freeze it? Does the engine validate that it is frozen? Or does the engine reject it?
For simplicity, my weak preference is for the engine to simply throw if the reviver attempts to return any object other than the one it was passed.
Should
JSON.parseImmutabletake a reviver function, and if so, what should its behavior be?Assuming there is a reviver function: It seems straightforward that in cases where the reviver returns either a primitive or the same object it was passed, that it should behave just like the reviver in
JSON.parse. What's less obvious is what do if the reviver returns an object other than the object it was passed. Is it accepted without condition? Does the engine freeze it? Does the engine validate that it is frozen? Or does the engine reject it?For simplicity, my weak preference is for the engine to simply throw if the reviver attempts to return any object other than the one it was passed.