Comparing json 🛠️

I had two large sets of json output that should be the same. Do they match?

Attempt 1

Hmm, no line breaks, so diff isn't much use. Let's insert some with sed.

[nasty regex work happens here]

Hmm, it's grim. Keys are not in the same order, which doesn't really make them different but makes the diffing fail. And without indentation it's not very human readable. And, and, and...

Attempt 2

There are well known tools that will beautify json. I can't install them. Don't ask. But web searching suggested python. That might work.

python -m json.tool --sort-keys

Woo! Beautified and sorted. Diff is happy. There's a bunch of differences, which is bad, but I can see what they are, which is good.

(Mostly posting this in case I need it again one day.)

#json
back to gemlog