4 ms·
There are many use cases where you don't know the shape of the data. Many apps need to index or store or transform arbitrary key/value pairs, but without knowin
by lobster_johnson 10y ago
There are many use cases where you don't know the shape of the data. Many apps need to index or store or transform arbitrary key/value pairs, but without knowing anything about those keys or values mean. JSON is a schemaless interchange format, so those situations arise pretty much by default.
Not that I love this format -- fixing JSON needs a bit more effort, especially on syntax.
- colanderman 10y ago> Many apps need to index or store or transform arbitrary key/value pairs, but without knowing anything about those keys or values mean. Then those apps shouldn't be interpreting those values. E.g. if you don't know and don't care whether a given JSON number is an integer or a decimal, don't represent it as a number in your app. Just copy the serialized number verbatim (or a canonicalized version thereof).
- lobster_johnson 10y agoOf course, if you're not touching it, that's a fine strategy. But maybe you're transforming it. Or you want to parse it, extract some value and send it somewhere. There are lots of use cases where there's no way around parsing and interpreting the data types in a JSON blob.
- colanderman 10y agoI don't mean the entire JSON structure. Go ahead and parse that; leave the individual values opaque.