News for hackers. Stuff that matters.
Re:Faster and simpler with the command line: deep-comparing ... by pritambaral on Thursday December 06, 2018 @01:39PM (#18620763)
Python's json package != JSON

JSON: https://tools.ietf.org/html/rfc8259#page-8

Re:Faster and simpler with the command line: deep-comparing ... by kemitche on Thursday December 06, 2018 @02:44PM (#18621361)
The link says that it's up to the implementation, which means it's valid for Python's JSON implementation to support larger numbers.

It's less "interoperable" but not strictly invalid, by my read.

Re:Faster and simpler with the command line: deep-comparing ... by derefr on Thursday December 06, 2018 @05:17PM (#18622914)
What the GP means is that JSON doesn't require an implementation to decode JSON integers as arbitrary-precision integers, to be "conformant JSON."

Therefore, you can't assume that if you pass some JSON through an arbitrary pipeline of JSON-manipulating tools, written in various languages, that your integer values will be passed through losslessly.

Therefore, you just shouldn't use JSON integer values when you know that the values can potentially be large. This is why e.g. Ethereum's JSON-RPC API uses hex-escaped strings (e.g. "0x0") for representing its "quantity" type.

Re:Faster and simpler with the command line: deep-comparing ... by yonatank on Thursday December 06, 2018 @02:54PM (#18621482)
It looks like JSON doesn't specifically define how numeric numbers should be stored. It just recommends expecting precision up to the double precision limits.

Still interesting to know it's not just a jq quirk.