Hacker News new | ask | show | jobs
by latch 3504 days 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('[]')))
1 comments

Another 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.