5 ms·
The json module returns heterogenous dicts. https://docs.python.org/3/library/json.html https://docs.python.org/3/library/json.html
by itishappy 2y ago
The json module returns heterogenous dicts.
https://docs.python.org/3/library/json.html https://docs.python.org/3/library/json.html
- bpshaver 2y agoYeah, just because it can do that doesn't mean that it is good design.
- gpderetta 2y agohow would you represent an arbitrary JSON array in python then? A potentially heterogeneous list seems the obvious solution.
- bpshaver 2y agoWhy would I want to do that? I'm rarely ingesting arbitrary JSON. Rather I'm designing my data structures in a sensible way and then maybe serializing them to JSON. Just because JSON can represent heterogenous lists doesn't mean it is a good idea to use heterogenous lists in my programs.
- gpderetta 2y agoThe JSON spec does not require a schema. If you want to write a library that can support any valid JSON you have little options. That's useful if you are implementing something like jq just to give an example.
- gwking 2y agoIt is the design of JSON! Which is a reflection of the same dynamic typing choice made in the original design of Javascript.
- mrguyorama 2y agoThey, uh, still aren't wrong hah. Tell me again why we somehow standardized on sending the equivalent of JSObject.toString() for everything? Especially when "standardized" isn't