title: Formatting JSON data to be displayed by a JSTree
body: <p><strong>EDIT:</strong> Found the answer I was looking for <a href="https://stackoverflow.com/questions/2514795/convert-json-structure">here</a>.</p>
  
  <p>I've got JSON data that I've obtained by using the <a href="https://code.google.com/p/google-gson/" rel="nofollow noreferrer">GSON</a> library. It is in the following format:</p>
  
  <pre><code>{
  "results": [
      {
      "foo1":"bar1",
      "foo2":"bar2",
      "foo3":"bar3"
      },
      {
      "foo4":"bar4",
      "foo5":"bar5",
      "foo6":"bar6"
      },
  ...(continued)...
  }
  </code></pre>
  
  <p>In order to upload it to a JSTree, it needs to be in this type of format:</p>
  
  <pre><code>"data" : [ {
          "data" : "results",
          "children" : [ {
              "data" : "foo1"
                  "children" : [{
                      "data": "bar1"
                  }]
          }, {
              "data" : "foo2"
                  "children" : [{
                  "data": "bar2"
                  }]
          }, {
              "data" : "foo3"
                  "children" : [{
                  "data": "bar3"
                  }]
          } ]
              ...(continued)...
  </code></pre>
  
  <p>Is there a library that would take in an object and output JSON in the latter format? Or will it be necessary to parse through the former JSON data and convert it to the latter format? Thanks in advance.</p>