I have a bunch of automatically generated JSON files that I want to store in version control. The problem is that each time the files are serialized, the attributes come out in a different order, making it hard to know if the files have really changed and / or what the real differences are.
Does anyone know of an existing open source tool that will perform this task?
Failing that, does anyone know of a JSON library with a parser and a generator that can be configured to output "pretty" JSON with the attributes in (say) lexical order? (A Java or Ruby library would be ideal, but other leads are also welcome.)
Python's JSON module is very usable from other programs:
generate_json | python -mjson.tool > canonical.json