1# <small>nlohmann::basic_json::</small>operator>
2
3```cpp
4// until C++20
5bool operator>(const_reference lhs, const_reference rhs) noexcept;   // (1)
6
7template<typename ScalarType>
8bool operator>(const_reference lhs, const ScalarType rhs) noexcept;  // (2)
9
10template<typename ScalarType>
11bool operator>(ScalarType lhs, const const_reference rhs) noexcept;  // (2)
12```
13
141. Compares whether one JSON value `lhs` is greater than another JSON value `rhs` according to the
15  following rules:
16    - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either
17      operand is `NaN` and the other operand is either `NaN` or any other number.
18    - Otherwise, returns the result of `#!cpp !(lhs <= rhs)` (see [**operator<=**](operator_le.md)).
19
202. Compares wether a JSON value is greater than a scalar or a scalar is greater than a JSON value by
21   converting the scalar to a JSON value and comparing both JSON values according to 1.
22
23## Template parameters
24
25`ScalarType`
26:   a scalar type according to `std::is_scalar<ScalarType>::value`
27
28## Parameters
29
30`lhs` (in)
31:   first value to consider 
32
33`rhs` (in)
34:   second value to consider 
35
36## Return value
37
38whether `lhs` is greater than `rhs`
39
40## Exception safety
41
42No-throw guarantee: this function never throws exceptions.
43
44## Complexity
45
46Linear.
47
48## Notes
49
50!!! note "Comparing `NaN`"
51
52    `NaN` values are unordered within the domain of numbers.
53    The following comparisons all yield `#!cpp false`:
54      1. Comparing a `NaN` with itself.
55      2. Comparing a `NaN` with another `NaN`.
56      3. Comparing a `NaN` and any other number.
57
58!!! note "Operator overload resolution"
59
60    Since C++20 overload resolution will consider the _rewritten candidate_ generated from
61    [`operator<=>`](operator_spaceship.md).
62
63## Examples
64
65??? example
66
67    The example demonstrates comparing several JSON types.
68        
69    ```cpp
70    --8<-- "examples/operator__greater.cpp"
71    ```
72    
73    Output:
74    
75    ```json
76    --8<-- "examples/operator__greater.output"
77    ```
78
79## See also
80
81- [**operator<=>**](operator_spaceship.md) comparison: 3-way
82
83## Version history
84
851. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0.
862. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0.
87