I'm sure this is simple but my heads not with it today, I'm trying to output a JSON file in this format:
{"A": {"B": [1, 1, 1, 1, 1, 1]}}
My code so far is:
jsonobj = {"A":{"B":[]
},
}
var1 = 1
jsonobj["A"]["B"].append(dict(f=var1))
with open('data.json', 'w') as f:
json.dump(jsonobj, f)
print jsonobj
As you can guess its a mismatch of code from StackOverflow and outputting wrong,
{'A': {'B': [{'f': 1}]}}
Sure it's an easy one, Thanks in advance.
jsonobj = {"A": {"B": [1, 1, 1, 1, 1, 1]}}, what's the dynamic part?