3 ms·
Not a python developer so I was surprised when the built-in json library has a flag allow_nan which is True by default. Also, not invalid, but surprising / ann
by latch 10y ago
Not a python developer so I was surprised when the built-in json library has a flag allow_nan which is True by default.
Also, not invalid, but surprising / annoying (a while to debug). An empty lua table is the same as an empty lua array: {}. This causes ambiguity.
// will print {}
print(cjson.encode(cjson.decode('[]')))
- amyjess 10y agoAnother nice feature of the built-in JSON library is that you can choose what class to instantiate with the data. The default is a dict, but if you're trying to parse Avro records (or something else that cares about field order), you can change that to an OrderedDict.