title: Using jq or alternative command line tools to compare JSON files
body: <p>Are there any command line utilities that can be used to find if two JSON files are identical with invariance to within-dictionary-key and within-list-element ordering?</p>
  
  <p>Could this be done with <a href="http://stedolan.github.io/jq/" rel="noreferrer"><code>jq</code></a> or some other equivalent tool?</p>
  
  <h2>Examples:</h2>
  
  <p>These two JSON files are identical</p>
  
  <p><code>A</code>:</p>
  
  <pre><code>{
    "People": ["John", "Bryan"],
    "City": "Boston",
    "State": "MA"
  }
  </code></pre>
  
  <p><code>B</code>:</p>
  
  <pre><code>{
    "People": ["Bryan", "John"],
    "State": "MA",
    "City": "Boston"
  }
  </code></pre>
  
  <p>but these two JSON files are different:</p>
  
  <p><code>A</code>:</p>
  
  <pre><code>{
    "People": ["John", "Bryan", "Carla"],
    "City": "Boston",
    "State": "MA"
  }
  </code></pre>
  
  <p><code>C</code>:</p>
  
  <pre><code>{
    "People": ["Bryan", "John"],
    "State": "MA",
    "City": "Boston"
  }
  </code></pre>
  
  <p>That would be:</p>
  
  <pre><code>$ some_diff_command A.json B.json
  
  $ some_diff_command A.json C.json
  The files are not structurally identical
  </code></pre>