Use to_json instead of JSON.dump as it handles certain types better