I'm currently writing a modding tool and as part of that I need to be able to read in text based game data files. I am currently reading them into my program and converting them to a dictionary like string format e.g.
{"add_namespace":"ace_promoted",
"add_namespace":"ace_died",
"add_namespace":"ace_killed_by_ace",
"add_namespace":"ace_killed_other_ace",
"add_namespace":"aces_killed_each_other",
"country_event":{"id":"ace_promoted.1",
"title":"ace_promoted.1.t",
"desc":{"text":"ace_promoted.1.d",
"trigger":{"NOT":{"tag":"GER"},
"NOT":{"tag":"ITA"},
"NOT":{"tag":"FRA"},
"NOT":{"tag":"JAP"},
"NOT":{"tag":"USA"},
"NOT":{"tag":"ENG"},
"NOT":{"tag":"SOV"}}}
etc...
when I use
ast.literal_eval(dict_string)
it converts the string in a dictionary but the duplicate keys mean that many values are lost as only the last is kept. Is there a way to merge these values into a list automatically so none are lost?