This is a first stab. Looking for comments and review. It's pretty raw
at the moment, but it does work for me. I still need to do nested
objects, but if people are happy with it now, we can bring it into the tree
and add the nested bit after that (which would be my preference).
Keep your eyes peeled for leaks and broken bits, as I'm sure there are some :)