Support for asJson

Implement asJson on resources to give a different server-side
representation of the object. Called prior to create and update.