I really enjoyed this article, and I think it shows how successfully jq fits into the Unix culture of sed/awk/grep/etc. It seems so rare to find new CLUI tools that feel as "classical" as jq. It has helped me do one-off tasks like this several times, but I've really only scratched the surface. Often with newer tools I'm reluctant to invest in going deeper into really learning the features, but with jq I have a lot of…
Faster and simpler with the command line: deep-comparing JSON files with jq
61–70 of 93 posts
Re: Faster and simpler with the command line: deep-comparing JSON files with jq
#62Earlier quoted context omitted.
Yikes, that's nasty.
It is. But it's a problem of JSON itself, not just jq.
>JSON is agnostic about the semantics of numbers ... JSON instead offers only the representation of numbers that humans use: a sequence of digits.
So... anything is valid, per the spec.
Re: Faster and simpler with the command line: deep-comparing JSON files with jq
#63> What’s the best way to compare these two 5GB files? A much simpler way to do this is simply to hash the files, for example using sha256sum, which AFAIK ships with just about every Linux distro. Then just compare the hashes.
Re: Faster and simpler with the command line: deep-comparing JSON files with jq
#64Earlier quoted context omitted.
JSON != JavaScript > echo 1152921504606846976 | python -c 'import sys, json; print(json.load(sys.stdin))' 1152921504606846976
Python's json package != JSON JSON: https://tools.ietf.org/html/rfc8259#page-8
It's less "interoperable" but not strictly invalid, by my read.
Re: Faster and simpler with the command line: deep-comparing JSON files with jq
#65Earlier quoted context omitted.
JSON != JavaScript > echo 1152921504606846976 | python -c 'import sys, json; print(json.load(sys.stdin))' 1152921504606846976
Python's json package != JSON JSON: https://tools.ietf.org/html/rfc8259#page-8
Still interesting to know it's not just a jq quirk.
Re: Faster and simpler with the command line: deep-comparing JSON files with jq
#66I wanted to like jq, but honestly, I can't figure out it's crazy syntax.
Re: Faster and simpler with the command line: deep-comparing JSON files with jq
#67Earlier quoted context omitted.
It is. But it's a problem of JSON itself, not just jq.
JSON != JavaScript > echo 1152921504606846976 | python -c 'import sys, json; print(json.load(sys.stdin))' 1152921504606846976
Re: Faster and simpler with the command line: deep-comparing JSON files with jq
#68Re: Faster and simpler with the command line: deep-comparing JSON files with jq
#69Earlier quoted context omitted.
Yes, you're totally correct. Using a heavyweight solution like JSON is beyond the pale, I should use a much more lightweight approach involving a database server. Your tone is oddly superior in your reply, which is really at odds with the technical content of your messages. > if record fields are consistent This is all very confused. The issue is that the JSON fields where not consistent compared to the baseline. So…
Like a SQLite DB? Actually, why don't we just transfer stuff as SQLite DBs. Single file, built-in schema, you can index. I mean, HDF is super-general and stuff, but it looks like SQLite would solve all the trouble with CSVs.
Re: Faster and simpler with the command line: deep-comparing JSON files with jq
#70I really enjoyed this article, and I think it shows how successfully jq fits into the Unix culture of sed/awk/grep/etc. It seems so rare to find new CLUI tools that feel as "classical" as jq. It has helped me do one-off tasks like this several times, but I've really only scratched the surface. Often with newer tools I'm reluctant to invest in going deeper into really learning the features, but with jq I have a lot of…
Even when reading the article I thought about it :)