json - Python - How to copy all data out of an array -
currently exporting database firebase json coming out in array.
[{"connectiontime": 19.23262298107147, "objectid": "01331oxpvt", "firmwarerevision": "201504270003 img-b", "deviceid": "edf02c74-6518-489e-8751-25c58f8c830d", "peripheraltype": 4, "updatedat": "2015-10-09t04:01:39.569z", "model": "bean", "hardwarerevision": "e", "serial": "serial number", "createdat": "2015-10-09t04:01:39.569z", "manufacturer": "punch through design"}, {"connectiontime": 0.3193170428276062, "objectid": "018mv1g6i8", "deviceid": "42635033-df3a-4109-a633-c3ab829be114", "peripheraltype": 2, "updatedat": "2015-12-08t04:20:41.950z", "createdat": "2015-12-08t04:20:41.950z"}]
and error - start of array encountered without start of object.'}]
how can change not array , list of data. need line break between each set of data im assuming once data out of array code have that. code below. help!
firebase = firebase.firebaseapplication('https://dataworks-356fa.firebaseio.com/') result = firebase.get('/connection_info_parse', none) # id_keys = map(str, result.keys()) #filter out id names open("firetobqrestore1.json", "w") outfile: # id in id_keys: json.dump(result, outfile, indent=none) outfile.write("\n")
it sounds in workflow wants newline delimited json, although haven't made explicitly clear giving error.
with caveat, think looking for:
import json open("firetobqrestore1.json", "w") outfile: line in result: json.dump(line, outfile, indent=none) outfile.write("\n")
this write individual json objects each line.
this assumes result
actual python object rather json string. if it's string need parse first like:
result = json.loads(result)
Comments
Post a Comment