1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-25 13:41:56 +03:00
Files
json/doc/mkdocs/docs/api/basic_json/operator_lt.md
Niels Lohmann 29cd970b94 Consolidate documentation (#3071)
* 🔥 consolidate documentation
* ♻️ overwork std specializations
* 🚚 move images files to mkdocs
* ♻️ fix URLs
* 🔧 tweak MkDocs configuration
* 🔧 add namespaces
* 📝 document deprecations
* 📝 document documentation generation
* 🚸 improve search
* 🚸 add examples
* 🚧 start adding documentation for macros
* 📝 add note for https://github.com/nlohmann/json/issues/874#issuecomment-1001699139
* 📝 overwork example handling
* 📝 fix Markdown tables
2021-12-29 13:41:01 +01:00

1.6 KiB

nlohmann::basic_json::operator<

bool operator<(const_reference lhs, const_reference rhs) noexcept;

template<typename ScalarType>
bool operator<(const_reference lhs, const ScalarType rhs) noexcept;

template<typename ScalarType>
bool operator<(ScalarType lhs, const const_reference rhs) noexcept;

Compares whether one JSON value lhs is less than another JSON value rhs according to the following rules:

  • If lhs and rhs have the same type, the values are compared using the default < operator.

  • Integer and floating-point numbers are automatically converted before comparison

  • Discarded values a

  • In case lhs and rhs have different types, the values are ignored and the order of the types is considered, which is:

    1. null
    2. boolean
    3. number (all types)
    4. object
    5. array
    6. string
    7. binary

    For instance, any boolean value is considered less than any string.

Template parameters

ScalarType
a scalar type according to std::is_scalar<ScalarType>::value

Parameters

lhs (in)
first value to consider
rhs (in)
second value to consider

Return value

whether lhs is less than rhs

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Linear.

Examples

??? example

The example demonstrates comparing several JSON types.
    
```cpp
--8<-- "examples/operator__less.cpp"
```

Output:

```json
--8<-- "examples/operator__less.output"
```

Version history

  • Added in version 1.0.0.