# nlohmann::basic_json::object_comparator_t ``` using object_comparator_t = typename object_t::key_compare; // or using object_comparator_t = default_object_comparator_t; ``` The comparator used by [`object_t`](https://json.nlohmann.me/api/basic_json/object_t/index.md). Defined as `typename object_t::key_compare` if available, and [`default_object_comparator_t`](https://json.nlohmann.me/api/basic_json/default_object_comparator_t/index.md) otherwise. ## Examples Example The example below demonstrates the used object comparator. ``` #include #include using nlohmann::json; int main() { std::cout << std::boolalpha << "json::object_comparator_t(\"one\", \"two\") = " << json::object_comparator_t{}("one", "two") << "\n" << "json::object_comparator_t(\"three\", \"four\") = " << json::object_comparator_t{}("three", "four") << '\n'; } ``` Output: ``` json::object_comparator_t("one", "two") = true json::object_comparator_t("three", "four") = false ``` ## See also - [`object_t`](https://json.nlohmann.me/api/basic_json/object_t/index.md) - the type used to store JSON objects - [`default_object_comparator_t`](https://json.nlohmann.me/api/basic_json/default_object_comparator_t/index.md) - the fallback comparator used when `object_t` has no `key_compare` member type - [Template Parameter Requirements](https://json.nlohmann.me/features/types/template_parameters/index.md) - requirements on the `ObjectType` template parameter - [Object order](https://json.nlohmann.me/features/object_order/index.md) - preserve the insertion order of keys ## Version history - Added in version 3.0.0. - Changed to be conditionally defined as `typename object_t::key_compare` or `default_object_comparator_t` in version 3.11.0. - Fixed the fallback to `default_object_comparator_t`, which previously failed to compile for object types without a `key_compare` member type, in version 3.13.0 unreleased.