I am currently writing an api response and the requirement is that all integers must inside double quotes. Ex:
{
"Key1": {"SubKey1":"1", "SubKey2":"2"},
"Key2": "2"
}
When I use json.dumps() to convert my dict to json str I'm getting this result:
{
"Key1": {"SubKey1":1, "SubKey2":2},
"Key2":2
}
(the values of keys are int objects in python). What should I do to make the values appear inside quotes?
I have tried casting them by using
string_ver = {str(key): str(d[key]) for key in d}
but this did not convert the values for subkey into strings (as expected)