Hacker News new | past | comments | ask | show | jobs | submit login

You've never had to read arbitrary json?



I just did a quick check (apparently DuckDuckGo has a built in JSON validation function lol love it) and `[1, "foo"]` does pass their JSON validation.

Not surprised but I did want to confirm.


Am I missing something, why wouldn't a non-homogeneous array literal pass?


Because mixing types in an array is stupid enough that I thought it might just not be valid.


Mixing types in an array/list is not remotely stupid. How exactly would you suggest expressing the lack of a value in a series of numbers without None/null? There's your mixed types.

Don't let weird dogma get in the way of practicality.


That's an Optional[int]. It's not "mixed types", it's a union type.


That is merely a detail of how the typing module has decided to set up convenient aliases. Treated by the language (and likely compilers) as different types.


JSON has a `null` value already, and null is its own special case in most languages where `null` is a universal type.

Otherwise you tag your data so that it's an array of objects.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: