How to convert a JSON object into a list collection?

One simple way to convert a JSON object into a list collection is by using the loads() function in the json library.

Here is a sample code:

bring in json

Define an example JSON object.

json object equal to ‘{“name”: “John”, “age”: 30, “city”: “New York”}’

Convert the JSON object to a Python dictionary using the loads() function.

Convert the JSON object into a Python dictionary using the json.loads method.

Convert a Python dictionary to a list collection.

Collect all the values from the dictionary python_dict and store them in a list called list_collection.

output the list_collection

The output is: [‘John’, 30, ‘New York’]

This successfully converted the JSON object into a list collection.

bannerAds