implement to_json and from_json on all model classes