Safely handle to_json without any keys