How to write json in specific format in python -


i want display json in specific format , data database.so how form in specific format in python.format of json is

 {        "data":{"device id" : value db,"date":current time},        "data":        {           "temperature":               {                 value db               },          "consumptions":             {                 value db             },          "error":            [               {                  value db               }            ]        }     } 

i have tried this:

dict((query.description[i][0], value) i, value in enumerate(row)) row in query.fetchall() 

but i'm not getting desired output , i'm unable pass data json. how pass data json.

error im getting dictionay update sequence element 0# has length 1; 2 required

did use json module?

import json  print json.dumps(yourstructure, indent=6) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -