4 ms·
As follows. It's more how the abstraction works. XML: ->[byte stream]->[deserializer]->[bignum] JSON: ->[byte stream]->[json reader]->[string]->[deseria
by bananas 13y ago
As follows. It's more how the abstraction works.
XML:
->[byte stream]->[deserializer]->[bignum]
JSON:
->[byte stream]->[json reader]->[string]->[deserializer]->[bignum]
The latter is, well, wrong.
- icebraining 13y agoMultiple JSON deserializers have that mapping integrating, eliminating those steps. See, for example, the ContextualDeserializer in Jackson.
- sanderjd 13y agoHow does the [deserializer] step in the XML example know to call into [bignum], and why can't the [json reader] in the JSON example have that knowledge in the same fashion?
- jdbernard 13y agoBecause the XML document has a semantic meaning that is specifically designed for this application. It may even have a schema definition document which formally defines what types to expect. JSON, by contrast, has type definitions imposed on it by its nature as JavaScript code.
- sanderjd 13y agoI've sort of lost track of what this debate is about... Assuming you don't have a schema definition, it seems to me that you can just as easily parse `{ "salary": "1e999" }` with application-encoded semantics as `<salary>1e999</salary>` with (again) application-encoded semantics. Maybe having a formal schema definition is a win, though.