Hacker News new | ask | show | jobs
by fsaintjacques 1331 days ago
JSON parsing is a minefield, especially in cross-platforms scenarios (language and/or library). You won't encounter those problems on toy project or simple CRUD applications. For example, as soon as you deal with (u)int64 where values are greater than 2^53, a simple round-trip to javascript can wreak silent havoc.

See http://seriot.ch/projects/parsing_json.html

Protobuf support for google's first-class citizen languages is usually very good, i.e. C++, Java, Python and Go. For other languages, it depends on each implementation.

2 comments

Though you're not wrong, in what common cases are integers larger than 2^53 required?
Timestamps in nanoseconds is one.
That's not common, JS's built in Date doesn't even support nanoseconds.
I guess it depends in which domain you work? In system programming, "clock_gettime" gives you nanoseconds. If you work with GPS timestamps, you have nanoseconds.

Could it be that JS's Date doesn't support nanoseconds because it cannot represent them, which is the issue we are talking about here?

Don't get me wrong, I understand this is not something that everyone uses every day, but to me it's a pretty straightforward example that can happen in a wide range of situations. It certainly happened to me/colleagues several times in several companies.

Nice article