Golang does typing, but JSONs are PITA to handle.
Try parsing something like `[{"a': 1, "b": "c", "d": [], "e": {}}, null, 1, "2"]` in go.
Types are a bless as well as a curse.
Golang does typing, but JSONs are PITA to handle.
Try parsing something like `[{"a': 1, "b": "c", "d": [], "e": {}}, null, 1, "2"]` in go.
Types are a bless as well as a curse.
We used to have strict typed XML. Nobody even bothered.
Not JSONs in general, but a sane API would never return something like that.
> We used to have strict typed XML. Nobody even bothered.
Nowadays there is OpenAPI, GraphQL, protobuf, etc. and people do bother about such things.
Yeah, because it was ugly as hell and not human-readable.
re: Python. I like PyRight/PyLance for Python typing, it seems to "just work" afaict. I also like msgspec for dataclass like behavior [2].
---
But the same issue exists as other dynamic languages, how do you know what the type is of the item you are accessing?
If you know the array will be laid out exactly like that before you make the request you can always create a custom parser to return a struct with those fields name what they actually are instead of arbitrary data.
The only valid way to parse that dynamically is to try and fail in a loop which is inefficient enough that you should stop using whatever API returns that monstrosity.