added support for as_json, which Rails uses for serialization.