I have written a Python script that outputs a long data structure (dictionary i called "celldict") in Json format. Here's a small part of it :
{
"1224": {
"OUT3FA_5": 12,
"IN1": 37,
"Total_IN1": 37
},
"1225": {
"OUT3FA_5": 24,
"IN1": 59,
"Total_IN1": 22
}
}
But what I would like to do is have something like this :
{
"success": true,
"data": [
{
"Week":"1224",
"OUT3FA_5": 65,
"IN1": 85,
"Total_IN1": 100
},
{
"Week":"1225",
"OUT3FA_5": 30,
"IN1": 40,
"Total_IN1": 120
}
]
}
Is there a way to format the json output with Python to get I what I want? I do:
print json.dumps(celldict)
to get my output. Any help would be much much appreciated.