title: Re-nesting a Json output in Python
body: <p>I have a json output in a loop and at the end of the loop I need to assign a unique key to the json. Something like the following :</p>
  
  <pre><code>out = {"34267":{"Annual Expenditure":250,"Annual Frequency":1,"Avg days":null,"First visit":1456012800000,"Frequency":1,"Last visit":1456012800000,"Merchants":32,"Monetory":250,"Recency":621,"Visit_Ids":[116644],"RFMClass":"244","AvgLTV":13305.7692307692},"101":{"Annual Expenditure":250,"Annual Frequency":1,"Avg days":null,"First visit":1423958400000,"Frequency":1,"Last visit":1423958400000,"Merchants":32,"Monetory":250,"Recency":992,"Visit_Ids":[1883],"RFMClass":"444","AvgLTV":13305.7692307692},"8877":{"Annual Expenditure":250,"Annual Frequency":1,"Avg days":null,"First visit":1459900800000,"Frequency":1,"Last visit":1459900800000,"Merchants":32,"Monetory":250,"Recency":576,"Visit_Ids":[141943],"RFMClass":"144","AvgLTV":13305.7692307692}}
  </code></pre>
  
  <p>But assign something like <code>out_final = {32: out}</code>, 
  makes the inner Json a string like the following :</p>
  
  <pre><code>{32: '{"34267":{"Annual Expenditure":250,"Annual Frequency":1,"Avg days":null,"First visit":1456012800000,"Frequency":1,"Last visit":1456012800000,"Merchants":32,"Monetory":250,"Recency":621,"Visit_Ids":[116644],"RFMClass":"244","AvgLTV":13305.7692307692},"101":{"Annual Expenditure":250,"Annual Frequency":1,"Avg days":null,"First visit":1423958400000,"Frequency":1,"Last visit":1423958400000,"Merchants":32,"Monetory":250,"Recency":992,"Visit_Ids":[1883],"RFMClass":"444","AvgLTV":13305.7692307692},"8877":{"Annual Expenditure":250,"Annual Frequency":1,"Avg days":null,"First visit":1459900800000,"Frequency":1,"Last visit":1459900800000,"Merchants":32,"Monetory":250,"Recency":576,"Visit_Ids":[141943],"RFMClass":"144","AvgLTV":13305.7692307692}}'}
  </code></pre>
  
  <p>This makes searching for a specific value impossible. Is there a way where I can assign the unique key without losing the inner structure.</p>
  
  <p>Like the following :</p>
  
  <pre><code>{32: {"34267":{"Annual Expenditure":250,"Annual Frequency":1,"Avg days":null,"First visit":1456012800000,"Frequency":1,"Last visit":1456012800000,"Merchants":32,"Monetory":250,"Recency":621,"Visit_Ids":[116644],"RFMClass":"244","AvgLTV":13305.7692307692},"101":{"Annual Expenditure":250,"Annual Frequency":1,"Avg days":null,"First visit":1423958400000,"Frequency":1,"Last visit":1423958400000,"Merchants":32,"Monetory":250,"Recency":992,"Visit_Ids":[1883],"RFMClass":"444","AvgLTV":13305.7692307692},"8877":{"Annual Expenditure":250,"Annual Frequency":1,"Avg days":null,"First visit":1459900800000,"Frequency":1,"Last visit":1459900800000,"Merchants":32,"Monetory":250,"Recency":576,"Visit_Ids":[141943],"RFMClass":"144","AvgLTV":13305.7692307692}}}
  </code></pre>