I'm trying to serialise a list of dictionaries as json files. Some of the values in the dictionaries are lists which are defined somewhere else. I would like to serialise the name of the list, not the "expanded" list. For example, say I have this:
list1 = ["A", "B", "C"]
dict1 = {
"key1": "foo",
"key2": list1
}
serialise_it(dict1)
If I just save the dict normally with the json package, it will contain:
{
"key1": "foo",
"key2": ["A", "B", "C"]
}
But I would like the resulting json file to contain:
{
"key1": "foo",
"key2": "list1"
}
Any ideas how to achieve this?
Thanks
EDIT: For clarification, I have a few list of lists each of hundreds of dictionaries which I am trying to convert into files. I'd rather not go through these manually adding quotation marks if there is a way to do it in code.