4 ms·
>I've seen integers sent as strings and others as integers in the same JSON. You still need to know what they are in each case, regardless of dynamic vs static
by coldtea 8y ago
>I've seen integers sent as strings and others as integers in the same JSON.
You still need to know what they are in each case, regardless of dynamic vs static typing (it's a matter of whether the language has weak vs strong typing or overly accommodating coercion).
If you get an integer value as string for example, Python won't let you add it to another integer you got as integer. So you'll need to know what they are to treat them accordingly in your processing even in a dynamic language.
In such case, you can also read them as a variant type on a static language, that's eg. one of the 7 allowed types in JSON (you don't know whether a JSON primitive might be int or string, but you know it wont be suddenly a Date type or a Foobar instance).