Added export_to_json and tests for it