string = “{
“Details”: “Featuring the “Last Post” and “Reveille” bugle signals, followed by a sermon and classical music pieces.”,
“Tags”: [“Commemoration”, “Media”, “National Belonging”, “War Remembrance”, “Interwar Period”]
}”
This string is in str type. I want to convert into dict type so that I can access each key in dict. JSON .loads() method can do it, but “Details” value contains “Last Post” and “Reveille” these two worlds, so loads() raise error.
I want to save that str into a JSON file as well. It should look like this,
{
"Details": "Featuring the "Last Post" and "Reveille" bugle signals, followed by a sermon and classical music pieces.",
"Tags": ["Commemoration", "Media", "National Belonging", "War Remembrance", "Interwar Period"]
}
How to do it
Try to convert str into dict
1