wrap to_json in a rescue