I'm trying to generate a JSON string using .format(). I tried the following:
TODO_JSON = '{"id": {0},"title": {1},"completed:" {2}}'
print(TODO_JSON.format(42, 'Some Task', False))
which raises
File "path/to/file", line 2, in <module>
print(TODO_JSON.format(42, 'Some Task', False))
KeyError: '"id"'
Why is this error occurring ? Why is 'id' getting interpreted as a key and not as part of a string ?
jsonmodule for practical work as it'll escape things for you.