converting text file into json format
<p>I have a file in format:</p>

<pre><code>{ 'name':50,
  'ntokens':12345,
  'values':[ 
             [
              ["abc" , 1234],
              ["foo" , 12234]
             ],
             [ 
              ["foobar",483]
             ]
          ]

}
</code></pre>

<p>I want to hammer this file into this format:</p>

<pre><code>{ 
  { "name":"cluster 1",
     "children": [ 
               {"name": "abc","size":1234},
               {"name": "foo","size":12234}
              ]
  },
  { "name":"cluster 2",
     "children": [ 
               {"name": "foobar" ,"size":483}
              ]
   }
}
</code></pre>

<p>My attempt has been very fragile. :(</p>

<p>I am reading thru file and creating bunch of regex rules. Not being able to get my head around.</p>

<p>I am almost sure there should be a pythnoic way (maybe json??) to resolve this?</p>

<p>Any suggestions will be very helpful.</p>

<p>Thanks</p>
