Handle to_json and from_json.