The code shown here defines a very simple object class, a vm (virtual machine), that includes name and state attributes and a list of disks. My class isn't very useful as it is, but the idea is to show that we can handle both simple string as well as list attributes.
The code creates a few vm objects and stores them in a list. Then, a list is created using the vm objects' dictionaries. The dictionaries themselves are very close to JSON as it is, but not quite in formal JSON, so the json.dumps method is used to get the data into JSON format.
Finally, the JSON data is converted back into vm objects using the json.loads method. The object_hook tells json.loads to use the as_vm function to recreate the objects.