I need to make JSON output that looks like the following
{ "items": [
"number": {
"value": 23
"label": test
}
]
}
I've done something similar with the code below but I can't figure out how I need to nest number under items.
#!/usr/bin/python
import json
myjson = {'items':[]}
d = {}
d['value'] = 23
d['label'] = "test"
myjson.get('items').append(d)
output = json.dumps(myjson)
print output
That gives me
{
"items": [{
"value": 23,
"label": "test"}
]}
["x": blah]
. The colon can only occur inside{}
, not directly inside[]
. – BrenBarn Sep 16 '15 at 2:57