#to_hash and #to_json (untested).