I have a class that looks like this:
class Car:
def __init__(self, name, colour, wheels):
self.name = name
self.colour = colour
self.wheels = wheels
I would like to create objects of the above class from the JSON file, which looks like this but with many entries:
"Cars":[
{
"name": "Golf",
"colour": "red",
"wheels": 4,
},
{
"name": "Up",
"colour": "green",
"wheels": 3,
}
]
And then add them to a dictionary with the layout {"name":object}. I've looked at the different tutorials and examples available, but most seems to be about dumping objects, not pulling them out and recreating objects from them.
Carsobject in the JSON mean anything? For example, the second object has a key ofRobin, should anything be done with that?Carsvalue to be a list rather than an object (eg.[instead of{).