completely untested to_json() code for models. probably doesn't work