comparison operator for JSON types
Returns an ordering that is similar to Python:
- order: null < boolean < number < object < array < string < binary
- furthermore, each type is not smaller than itself
- discarded values are not comparable
- binary is represented as a b"" string in python and directly comparable to a string; however, making a binary array directly comparable with a string would be surprising behavior in a JSON file.
- Since
- version 1.0.0
Definition at line 147 of file json.hpp.
148{
149 static constexpr std::array<std::uint8_t, 9> order = {{
150 0 , 3 , 4 , 5 ,
151 1 , 2 , 2 , 2 ,
152 6
153 }
154 };
155 const auto l_index = static_cast<std::size_t>(lhs);
156 const auto r_index = static_cast<std::size_t>(rhs);
157 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
158}