DEV Community

Discussion on: Pretty print JSON using the command line tools

Collapse
andypiper profile image
Andy Piper

Sure. Let's assume the following small JSON:

{
  "id": 1130950371172638721,
  "id_str": "1130950371172638721"
}

(hint, these are values from a Tweet object in the Twitter API)

Now, let's parse this with jq:

$ jq < simple.json
{
  "id": 1130950371172638700,
  "id_str": "1130950371172638721"
}

The large integer value is mangled, because JavaScript (jQuery) does not like values larger than 53 bits. This is the reason that Twitter ended up serving IDs as both integer values and as strings (read more here)

Thread Thread
tbutterwith profile image
Tom Butterwith

Well every day is a learning day. I didn't know C had the same issues as JS with integer parsing.

Thanks for clarifying.

Thread Thread
andypiper profile image
Andy Piper

I guess this issue is relevant here:

github.com/stedolan/jq/issues/369