Improved back end to support JSON serialization via todict and fromdict methods

Each object now has todict() and fromdict() methods which can be used in conjunction with the json library in order to serialize them for transport over HTTP connection.