2 ms·
>A dictionary is a key/value map, period. If you want to use that, because you don't want to do the encode/decode ceremony, then you are doing stringly-typed co
by coldtea 8y ago
>A dictionary is a key/value map, period. If you want to use that, because you don't want to do the encode/decode ceremony, then you are doing stringly-typed code in a statically typed language.
It's not stringy-typed since all the scalars have the proper type as they did on the "wire". In JSON you have string, booleans, floats, objects, arrays, and null.
And JSON is not a general serialization format (e.g. all object keys are strings, all numeric values are floats), so this "encode/decode" ceremony just introduces a layer that isn't there to begin with (and would fail without custom decoders for things like dates and so on).
In general the decode is really a mapping for convenience and schema validation, than an actual decode of what the JSON contains (since JSON knows nothing about those structs as structs).
- the_gipsy 8y agoi never referred to values, but the structure. hammering json into a dict is stringly-typed. it is stringly typed when you do foo[“bar”][“baz”] etc. foo.bar.baz would be typesafe.