mirror of
https://github.com/nlohmann/json.git
synced 2025-08-07 18:02:57 +03:00
💡 update documentation
This commit is contained in:
@@ -902,8 +902,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
#### Notes on subtypes
|
||||
|
||||
- CBOR
|
||||
- Binary values are represented as byte strings. No subtypes are
|
||||
supported and will be ignored when CBOR is written.
|
||||
- Binary values are represented as byte strings. Subtypes are serialized
|
||||
as tagged values.
|
||||
- MessagePack
|
||||
- If a subtype is given and the binary array contains exactly 1, 2, 4, 8,
|
||||
or 16 elements, the fixext family (fixext1, fixext2, fixext4, fixext8)
|
||||
@@ -1497,7 +1497,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
@ref number_float_t, and all convertible number types such as `int`,
|
||||
`size_t`, `int64_t`, `float` or `double` can be used.
|
||||
- **boolean**: @ref boolean_t / `bool` can be used.
|
||||
- **binary**: @ref binary_t / `std::vector<uint8_t>` may be used,
|
||||
- **binary**: @ref binary_t / `std::vector<std::uint8_t>` may be used,
|
||||
unfortunately because string literals cannot be distinguished from binary
|
||||
character arrays by the C++ type system, all types compatible with `const
|
||||
char*` will be directed to the string constructor instead. This is both
|
||||
@@ -7187,6 +7187,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
binary | *size*: 65536..4294967295 | byte string (4 bytes follow) | 0x5A
|
||||
binary | *size*: 4294967296..18446744073709551615 | byte string (8 bytes follow) | 0x5B
|
||||
|
||||
Binary values with subtype are mapped to tagged values (0xD8..0xDB)
|
||||
depending on the subtype, followed by a byte string, see "binary" cells
|
||||
in the table above.
|
||||
|
||||
@note The mapping is **complete** in the sense that any JSON value type
|
||||
can be converted to a CBOR value.
|
||||
|
||||
@@ -7227,16 +7231,16 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
@since version 2.0.9; compact representation of floating-point numbers
|
||||
since version 3.8.0
|
||||
*/
|
||||
static std::vector<uint8_t> to_cbor(const basic_json& j)
|
||||
static std::vector<std::uint8_t> to_cbor(const basic_json& j)
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
std::vector<std::uint8_t> result;
|
||||
to_cbor(j, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void to_cbor(const basic_json& j, detail::output_adapter<uint8_t> o)
|
||||
static void to_cbor(const basic_json& j, detail::output_adapter<std::uint8_t> o)
|
||||
{
|
||||
binary_writer<uint8_t>(o).write_cbor(j);
|
||||
binary_writer<std::uint8_t>(o).write_cbor(j);
|
||||
}
|
||||
|
||||
static void to_cbor(const basic_json& j, detail::output_adapter<char> o)
|
||||
@@ -7322,16 +7326,16 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
@since version 2.0.9
|
||||
*/
|
||||
static std::vector<uint8_t> to_msgpack(const basic_json& j)
|
||||
static std::vector<std::uint8_t> to_msgpack(const basic_json& j)
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
std::vector<std::uint8_t> result;
|
||||
to_msgpack(j, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void to_msgpack(const basic_json& j, detail::output_adapter<uint8_t> o)
|
||||
static void to_msgpack(const basic_json& j, detail::output_adapter<std::uint8_t> o)
|
||||
{
|
||||
binary_writer<uint8_t>(o).write_msgpack(j);
|
||||
binary_writer<std::uint8_t>(o).write_msgpack(j);
|
||||
}
|
||||
|
||||
static void to_msgpack(const basic_json& j, detail::output_adapter<char> o)
|
||||
@@ -7425,19 +7429,19 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
@since version 3.1.0
|
||||
*/
|
||||
static std::vector<uint8_t> to_ubjson(const basic_json& j,
|
||||
const bool use_size = false,
|
||||
const bool use_type = false)
|
||||
static std::vector<std::uint8_t> to_ubjson(const basic_json& j,
|
||||
const bool use_size = false,
|
||||
const bool use_type = false)
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
std::vector<std::uint8_t> result;
|
||||
to_ubjson(j, result, use_size, use_type);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void to_ubjson(const basic_json& j, detail::output_adapter<uint8_t> o,
|
||||
static void to_ubjson(const basic_json& j, detail::output_adapter<std::uint8_t> o,
|
||||
const bool use_size = false, const bool use_type = false)
|
||||
{
|
||||
binary_writer<uint8_t>(o).write_ubjson(j, use_size, use_type);
|
||||
binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
|
||||
}
|
||||
|
||||
static void to_ubjson(const basic_json& j, detail::output_adapter<char> o,
|
||||
@@ -7503,9 +7507,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
@sa see @ref to_cbor(const basic_json&) for the related CBOR format
|
||||
@sa see @ref to_msgpack(const basic_json&) for the related MessagePack format
|
||||
*/
|
||||
static std::vector<uint8_t> to_bson(const basic_json& j)
|
||||
static std::vector<std::uint8_t> to_bson(const basic_json& j)
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
std::vector<std::uint8_t> result;
|
||||
to_bson(j, result);
|
||||
return result;
|
||||
}
|
||||
@@ -7518,13 +7522,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
@pre The input `j` shall be an object: `j.is_object() == true`
|
||||
@sa see @ref to_bson(const basic_json&)
|
||||
*/
|
||||
static void to_bson(const basic_json& j, detail::output_adapter<uint8_t> o)
|
||||
static void to_bson(const basic_json& j, detail::output_adapter<std::uint8_t> o)
|
||||
{
|
||||
binary_writer<uint8_t>(o).write_bson(j);
|
||||
binary_writer<std::uint8_t>(o).write_bson(j);
|
||||
}
|
||||
|
||||
/*!
|
||||
@copydoc to_bson(const basic_json&, detail::output_adapter<uint8_t>)
|
||||
@copydoc to_bson(const basic_json&, detail::output_adapter<std::uint8_t>)
|
||||
*/
|
||||
static void to_bson(const basic_json& j, detail::output_adapter<char> o)
|
||||
{
|
||||
|
Reference in New Issue
Block a user