mirror of
https://github.com/nlohmann/json.git
synced 2025-07-29 23:01:16 +03:00
📝 add documentation for numbers
This commit is contained in:
@ -6,7 +6,7 @@ using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
|
||||
|
||||
The type used to store JSON arrays.
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) describes JSON arrays as follows:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows:
|
||||
> An array is an ordered sequence of zero or more values.
|
||||
|
||||
To store objects in C++, a type is defined by the template parameters explained below.
|
||||
@ -35,7 +35,7 @@ std::vector<
|
||||
|
||||
#### Limits
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) specifies:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies:
|
||||
> An implementation may set limits on the maximum depth of nesting.
|
||||
|
||||
In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be
|
||||
|
@ -6,7 +6,7 @@ using boolean_t = BooleanType;
|
||||
|
||||
The type used to store JSON booleans.
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) implicitly describes a boolean as a type which differentiates the two literals
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a type which differentiates the two literals
|
||||
`#!json true` and `#!json false`.
|
||||
|
||||
To store objects in C++, a type is defined by the template parameter `BooleanType` which chooses the type to use.
|
||||
|
@ -6,7 +6,7 @@ using number_float_t = NumberFloatType;
|
||||
|
||||
The type used to store JSON numbers (floating-point).
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows:
|
||||
> The representation of numbers is similar to that used in most programming languages. A number is represented in base
|
||||
> 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may
|
||||
> be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that
|
||||
@ -35,7 +35,7 @@ With the default values for `NumberFloatType` (`double`), the default value for
|
||||
|
||||
#### Limits
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) states:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) states:
|
||||
> This specification allows implementations to set limits on the range and precision of numbers accepted. Since software
|
||||
> that implements IEEE 754-2008 binary64 (double precision) numbers is generally available and widely used, good
|
||||
> interoperability can be achieved by implementations that expect no more precision or range than these provide, in the
|
||||
|
@ -6,7 +6,7 @@ using number_integer_t = NumberIntegerType;
|
||||
|
||||
The type used to store JSON numbers (integers).
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows:
|
||||
> The representation of numbers is similar to that used in most programming languages. A number is represented in base
|
||||
> 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may
|
||||
> be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that
|
||||
@ -36,7 +36,7 @@ With the default values for `NumberIntegerType` (`std::int64_t`), the default va
|
||||
|
||||
#### Limits
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) specifies:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies:
|
||||
> An implementation may set limits on the range and precision of numbers.
|
||||
|
||||
When the default type is used, the maximal integer number that can be stored is `9223372036854775807` (INT64_MAX) and
|
||||
@ -44,7 +44,7 @@ the minimal integer number that can be stored is `-9223372036854775808` (INT64_M
|
||||
range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers
|
||||
will be automatically be stored as [`number_unsigned_t`](number_unsigned_t.md) or [`number_float_t`](number_float_t.md).
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) further states:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) further states:
|
||||
> Note that when such software is used, numbers that are integers and are in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are
|
||||
> interoperable in the sense that implementations will agree exactly on their numeric values.
|
||||
|
||||
|
@ -6,7 +6,7 @@ using number_unsigned_t = NumberUnsignedType;
|
||||
|
||||
The type used to store JSON numbers (unsigned).
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows:
|
||||
> The representation of numbers is similar to that used in most programming languages. A number is represented in base
|
||||
> 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may
|
||||
> be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that
|
||||
@ -36,7 +36,7 @@ With the default values for `NumberUnsignedType` (`std::uint64_t`), the default
|
||||
|
||||
#### Limits
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) specifies:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies:
|
||||
> An implementation may set limits on the range and precision of numbers.
|
||||
|
||||
When the default type is used, the maximal integer number that can be stored is `18446744073709551615` (UINT64_MAX) and
|
||||
@ -44,7 +44,7 @@ the minimal integer number that can be stored is `0`. Integer numbers that are o
|
||||
when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored
|
||||
as [`number_integer_t`](number_integer_t.md) or [`number_float_t`](number_float_t.md).
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) further states:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) further states:
|
||||
> Note that when such software is used, numbers that are integers and are in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are
|
||||
> interoperable in the sense that implementations will agree exactly on their numeric values.
|
||||
|
||||
|
@ -9,7 +9,7 @@ using object_t = ObjectType<StringType,
|
||||
|
||||
The type used to store JSON objects.
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) describes JSON objects as follows:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON objects as follows:
|
||||
> An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a
|
||||
> string, number, boolean, null, object, or array.
|
||||
|
||||
@ -73,7 +73,7 @@ behavior:
|
||||
|
||||
#### Limits
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) specifies:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies:
|
||||
> An implementation may set limits on the maximum depth of nesting.
|
||||
|
||||
In this class, the object's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be
|
||||
@ -90,7 +90,7 @@ Objects are stored as pointers in a `basic_json` type. That is, for any access t
|
||||
The order name/value pairs are added to the object is *not* preserved by the library. Therefore, iterating an object may
|
||||
return name/value pairs in a different order than they were originally stored. In fact, keys will be traversed in
|
||||
alphabetical order as `std::map` with `std::less` is used by default. Please note this behavior conforms to
|
||||
[RFC 7159](http://rfc7159.net/rfc7159), because any order implements the specified "unordered" nature of JSON objects.
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259), because any order implements the specified "unordered" nature of JSON objects.
|
||||
|
||||
## Version history
|
||||
|
||||
|
@ -6,7 +6,7 @@ using string_t = StringType;
|
||||
|
||||
The type used to store JSON strings.
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) describes JSON strings as follows:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON strings as follows:
|
||||
> A string is a sequence of zero or more Unicode characters.
|
||||
|
||||
To store objects in C++, a type is defined by the template parameter described below. Unicode values are split by the
|
||||
@ -31,7 +31,7 @@ the number of bytes in the string rather than the number of characters or glyphs
|
||||
|
||||
#### String comparison
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) states:
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) states:
|
||||
> Software implementations are typically required to test names of object members for equality. Implementations that
|
||||
> transform the textual representation into sequences of Unicode code units and then perform the comparison numerically,
|
||||
> code unit by code unit, are interoperable in the sense that implementations will agree in all cases on equality or
|
||||
|
Reference in New Issue
Block a user