python json loads single quotes 1

python json loads single quotes

You must have double quotes for JSON, its JSON format.

IF python is making a dictionary with single quotes you will have to do the
replace "'" with '"' (replace single with double)

Here is what the above code is Doing:
1. It’s creating a dictionary with the key “name” and the value “John”
2. It’s creating a dictionary with the key “age” and the value “30”
3. It’s creating a dictionary with the key “married” and the value “True”
4. It’s creating a dictionary with the key “divorced” and the value “False”
5. It’s creating a dictionary with the key “children” and the value “[‘Ann’, ‘Billy’]”
6. It’s creating a dictionary with the key “pets” and the value “None”
7. It’s creating a dictionary with the key “cars” and the value “[{‘model’: ‘BMW 230’, ‘mpg’: 27.5}, {‘model’: ‘Ford Edge’, ‘mpg’: 24.1}]”

Similar Posts