News for hackers. Stuff that matters.
Re:Python dicts are now ordered by jwkane on Friday February 07, 2020 @03:20PM (#22270459)
It's significant to a human that wants to know what has changed.
Re:Python dicts are now ordered by philwelch on Friday February 07, 2020 @05:08PM (#22271577)
If a human is inspecting serialized JSON using pen and paper, the human is presumably clever enough to match up key for key regardless of ordering.

If the human is using a computer to compare two JSON payloads (as the use of a diffing algorithm suggests), the human and computer should be clever enough as a team to realize that they could just deserialize and reserialize each JSON payload such that the keys were lexicographically sorted and the data was pretty-printed in the exact same way before running it through the diffing algorithm. `jq -Sc` would do the trick.

Re:Python dicts are now ordered by zo1 on Saturday February 08, 2020 @06:49AM (#22275279)
Most diff programs don't have what you describe. And in a lot of cases you don't have the easy ability to "do stuff" before running the input through a diffing algorithm.
Re:Python dicts are now ordered by philwelch on Saturday February 08, 2020 @11:26AM (#22276532)
> Most diff programs don't have what you describe.

That’s why pipes were invented.

> And in a lot of cases you don't have the easy ability to "do stuff" before running the input through a diffing algorithm.

Well, in that case you’re not going to be able to meaningfully compare two JSON payloads because neither order nor white space have any semantic meaning in JSON. I’m really curious what you’re talking about though, since if you’re working on the shell you can easily use jq to do as I describe.