Re: [whatwg/fetch] Body.json reviver (#104)

@annevk 
Both methods are inside the core web platform and both parse serialized json into a JS object.

The key difference is (2) and implies (1) and (3): one operates on a stream of bytes (hence different name and returns a Promise) the other operates on a string.

The fact that their _input_ is different doesn't justify that the API surface of _parsing_ is different.

It's like saying: if you serialize JSON to a file you can choose some properties to omit, but not when you serialize JSON to a memory string where you can transform values, unlike when you serialize JSON to an HTTP body, in which case you can choose to transform camel-case to PascalCase.

Good API design is consistent and predictable.
Wherever the web platform exposes JSON parsing, it should expose the same parsing options.

Unless you consider revivers an obsolete feature? It's rather useful so I hope you don't.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/104#issuecomment-395081809

Received on Wednesday, 6 June 2018 14:09:27 UTC