title: How to cryptographically hash a JSON object?
body: <p>The following question is more complex than it may first seem. </p>
  
  <p>Assume that I've got an arbitrary JSON object, one that may contain any amount of data including other nested JSON objects.  What I want is a cryptographic hash/digest of the JSON data, without regard to the actual JSON formatting itself (eg: ignoring newlines and spacing differences between the JSON tokens).</p>
  
  <p>The last part is a requirement, as the JSON will be generated/read by a variety of (de)serializers on a number of different platforms.  I know of at least one JSON library for Java that completely removes formatting when reading data during deserialization.  As such it will break the hash.</p>
  
  <p>The arbitrary data clause above also complicates things, as it prevents me from taking known fields in a given order and concatenating them prior to hasing (think roughly how Java's non-cryptographic hashCode() method works).</p>
  
  <p>Lastly, hashing the entire JSON String as a chunk of bytes (prior to deserialization) is not desirable either, since there are fields in the JSON that should be ignored when computing the hash.</p>
  
  <p>I'm not sure there is a good solution to this problem, but I welcome any approaches or thoughts =)</p>