4 ms·
The problem with all (widely known) the non-standard JSON packages is, they all have their gotchas. cjson's way of handling unicode is just plain wrong: it use
by borman 11y ago
The problem with all (widely known) the non-standard JSON packages is, they all have their gotchas.
cjson's way of handling unicode is just plain wrong: it uses utf-8 bytes as unicode code points. ujson cannot handle large numbers (somewhat larger than 263, i've seen a service that encodes unsigned 64-bit hash values in JSON this way: ujson fails to parse its payloads). With simplejson (when using speedups module), string's type depends on its value, i.e. it decodes strings as 'str' type if their characters are ascii-only, but as 'unicode' otherwise; strangely enough, it always decodes strings as unicode (like standard json module) when speedups are disables.
- TazeTSchnitzel 11y agoThere are so many poorly-written JSON decoders out there. I've had the misfortune of fixing two of PHP's to follow JSON's case-sensitivity and whitspace rules properly.
- smerritt 11y agoAgreed, especially about simplejson. I work on a project that uses simplejson, and it leads to ugly type checking all over the place because you never know what your JSON string got turned into. For example: https://github.com/openstack/swift/blob/39c1362a4f5a7df75730d3388bf37c3b5fbdc9c8/swift/account/reaper.py#L362 https://github.com/openstack/swift/blob/39c1362a4f5a7df75730... and https://github.com/openstack/swift/blob/39c1362a4f5a7df75730d3388bf37c3b5fbdc9c8/swift/common/db.py#L51 https://github.com/openstack/swift/blob/39c1362a4f5a7df75730... and https://github.com/openstack/swift/blob/39c1362a4f5a7df75730d3388bf37c3b5fbdc9c8/swift/common/middleware/slo.py#L291 https://github.com/openstack/swift/blob/39c1362a4f5a7df75730... and many more just like those. The worst part is the bugs that appear or disappear depending on whether simplejson's speedups module is in use or not.