title: Groovy compare two json with unknown nodes names and values
body: <p>I have a rest API to test and I have to compare two json responses. Below you can find a structure of the file. Both files to compare should contains the same elements but order might be different. Unfortunately the names, the type (simple, array) and the number of keys (root, nodeXYZ) are also not known.</p>
  
  <pre><code>{"root": [{
     "node1": "value1",
     "node2": "value1",
     "node3":    [
              {
           "node311": "value311",
           "node312": "value312"
        },
              {
           "node321": "value321",
           "node322": "value322"
        }
     ],
     "node4":    [
              {
           "node411": "value411",
           "node412": "value413",
           "node413": [         {
              "node4131": "value4131",
              "node4132": "value4131"
           }],
           "node414": []
        }
        {
           "node421": "value421",
           "node422": "value422",
           "node423": [         {
              "node4231": "value4231",
              "node4232": "value4231"
           }],
           "node424": []
        }]
     "node5":    [
        {"node51": "value51"},
        {"node52": "value52"},
     ]
  }]}
  </code></pre>
  
  <p>I have found some useful information in 
  <a href="https://stackoverflow.com/questions/30600642/groovy-compare-two-json-objects-same-structure-and-return-arraylist-containi">Groovy - compare two JSON objects (same structure) and return ArrayList containing differences</a>
  <a href="https://stackoverflow.com/questions/18601228/getting-node-from-json-response">Getting node from Json Response</a>
  <a href="https://stackoverflow.com/questions/23654646/groovy-how-do-i-search-json-with-keys-value-and-find-its-children-in-groovy">Groovy : how do i search json with key&#39;s value and find its children in groovy</a>
  but I could not combine it to an solution. 
  I thought the solution might look like this:      </p>
  
  <pre><code>take root
  get root children names
  check if child has children and get their names
  do it to the lowest leve child
  </code></pre>
  
  <p>With all names in place comparing should be easy (I guess)
  Unfortunately I did not manage to get keys under root</p>