I have a number of string with json format such as '{"key1":{0}, "key2":{1}}'.
After I retrieve the json string and substitute with values.
'{"key1":{0}, "key2":{1}}'.format("value1", "value2"). # KeyError: '"key1"
The problem is caused by the bracket {, and I should use {{ and }} in the string, however, it is not easy to add { to the the string because the bracket may appear in the middle part such as '{"key1":{0}, "key2":{1}, "{3}":"value3"}'
How can I format the json string?
json.loadsjson.dumps.{number}is not a valid dictionary because it doesn't have any:'s in it.