1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

💡 update documentation

This commit is contained in:
Niels Lohmann
2021-08-08 13:24:17 +02:00
parent db7ccafbda
commit 523f7c2c9d
10 changed files with 80 additions and 63 deletions

View File

@ -4956,7 +4956,7 @@ struct adl_serializer
// #include <nlohmann/byte_container_with_subtype.hpp>
#include <cstdint> // uint8_t
#include <cstdint> // uint8_t, uint64_t
#include <tuple> // tie
#include <utility> // move
@ -4974,7 +4974,7 @@ order to override the binary type.
@tparam BinaryType container to store bytes (`std::vector<std::uint8_t>` by
default)
@since version 3.8.0
@since version 3.8.0; changed type of subtypes to std::uint64_t in 3.9.2.
*/
template<typename BinaryType>
class byte_container_with_subtype : public BinaryType
@ -5063,7 +5063,8 @@ class byte_container_with_subtype : public BinaryType
@sa see @ref has_subtype() -- returns whether or not the binary value has a
subtype
@since version 3.8.0
@since version 3.8.0; fixed return value to properly return
subtype_type(-1) as documented in version 3.9.2
*/
constexpr subtype_type subtype() const noexcept
{
@ -10783,7 +10784,7 @@ namespace detail
// parser //
////////////
enum class parse_event_t : uint8_t
enum class parse_event_t : std::uint8_t
{
/// the parser read `{` and started to process a JSON object
object_start,
@ -16468,7 +16469,7 @@ class serializer
for (std::size_t i = 0; i < s.size(); ++i)
{
const auto byte = static_cast<uint8_t>(s[i]);
const auto byte = static_cast<std::uint8_t>(s[i]);
switch (decode(state, codepoint, byte))
{
@ -18057,8 +18058,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)
@ -18652,7 +18653,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
@ -24342,6 +24343,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.
@ -24382,16 +24387,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)
@ -24477,16 +24482,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)
@ -24580,19 +24585,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,
@ -24658,9 +24663,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;
}
@ -24673,13 +24678,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)
{