I have a python dictionary with keys in the format Aa123 and each value is a list. Now I need to store this data permanently in some format or in any database so that I can retrieve it easily. I thought JSON would be better for this and tried to store all the data in JSON format and then some application could use this file. My JSON format should be like,
[
{ "firstLetter" : "A",
"remaining" : [
{
"secondLetter" : "a",
"ID" : [
{"id" : "Aa123", "listOfItems" : ["ABC123","ASD100"]},
{"id" : "Aa100", "listOfItems" : ["ABC123","COD101"]}
]
},
{
"secondLetter" : "b",
"ID" : [
{"id" : "Ab100", "listOfItems" : ["ABC123","ASD100"]}
]
}
]
},
{ "firstLetter" : "B",
"remaining" : [
{
"secondLetter" : "a",
"ID" : [
{"id" : "Ba106", "listOfItems" : ["AUD123","CML101"]}
]
},
{
"secondLetter" : "b",
"ID" : [
{"id" : "Bb153", "listOfItems" : ["AER113","ASD100"]},
{"id" : "Bb100", "listOfItems" : ["ATC123","ASD500"]}
]
}
]
}
]
I know how to dump python dictionary into JSON, but that doesn't provide easy data query. My question is "how to store this python dictionary(that I obtained by running a python program)in required format(like the one shown above) that makes data query easy. Thanks!
loadeddict = json.loads(retrieveddata)?