mirror of
https://github.com/nlohmann/json.git
synced 2025-07-29 23:01:16 +03:00
BJData Fixes (#4588)
This commit is contained in:
committed by
GitHub
parent
0cb1241d5e
commit
48e7b4c23b
@ -37,10 +37,11 @@ The exact mapping and its limitations is described on a [dedicated page](../../f
|
||||
|
||||
`use_type` (in)
|
||||
: whether to add type annotations to container types (must be combined with `#!cpp use_size = true`); optional,
|
||||
`#!cpp false` by default.
|
||||
|
||||
`version` (in)
|
||||
: which version of BJData to use (see [draft 3](../../features/binary_formats/bjdata.md#draft-3-binary-format)); optional,
|
||||
`#!cpp false` by default.
|
||||
: which version of BJData to use (see [draft 3](../../features/binary_formats/bjdata.md#draft-3-binary-format));
|
||||
optional, `#!cpp bjdata_version_t::draft2` by default.
|
||||
|
||||
## Return value
|
||||
|
||||
|
@ -748,7 +748,7 @@ class binary_writer
|
||||
const bool use_type, const bool add_prefix = true,
|
||||
const bool use_bjdata = false, const bjdata_version_t bjdata_version = bjdata_version_t::draft2)
|
||||
{
|
||||
const bool bjdata_draft3 = bjdata_version == bjdata_version_t::draft3;
|
||||
const bool bjdata_draft3 = use_bjdata && bjdata_version == bjdata_version_t::draft3;
|
||||
|
||||
switch (j.type())
|
||||
{
|
||||
@ -857,11 +857,11 @@ class binary_writer
|
||||
oa->write_character(to_char_type('['));
|
||||
}
|
||||
|
||||
if (use_type && ((use_bjdata && bjdata_draft3) || !j.m_data.m_value.binary->empty()))
|
||||
if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
|
||||
{
|
||||
JSON_ASSERT(use_count);
|
||||
oa->write_character(to_char_type('$'));
|
||||
oa->write_character(use_bjdata && bjdata_draft3 ? 'B' : 'U');
|
||||
oa->write_character(bjdata_draft3 ? 'B' : 'U');
|
||||
}
|
||||
|
||||
if (use_count)
|
||||
@ -880,7 +880,7 @@ class binary_writer
|
||||
{
|
||||
for (size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
|
||||
{
|
||||
oa->write_character(to_char_type((use_bjdata && bjdata_draft3) ? 'B' : 'U'));
|
||||
oa->write_character(to_char_type(bjdata_draft3 ? 'B' : 'U'));
|
||||
oa->write_character(j.m_data.m_value.binary->data()[i]);
|
||||
}
|
||||
}
|
||||
|
@ -16384,7 +16384,7 @@ class binary_writer
|
||||
const bool use_type, const bool add_prefix = true,
|
||||
const bool use_bjdata = false, const bjdata_version_t bjdata_version = bjdata_version_t::draft2)
|
||||
{
|
||||
const bool bjdata_draft3 = bjdata_version == bjdata_version_t::draft3;
|
||||
const bool bjdata_draft3 = use_bjdata && bjdata_version == bjdata_version_t::draft3;
|
||||
|
||||
switch (j.type())
|
||||
{
|
||||
@ -16493,11 +16493,11 @@ class binary_writer
|
||||
oa->write_character(to_char_type('['));
|
||||
}
|
||||
|
||||
if (use_type && ((use_bjdata && bjdata_draft3) || !j.m_data.m_value.binary->empty()))
|
||||
if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
|
||||
{
|
||||
JSON_ASSERT(use_count);
|
||||
oa->write_character(to_char_type('$'));
|
||||
oa->write_character(use_bjdata && bjdata_draft3 ? 'B' : 'U');
|
||||
oa->write_character(bjdata_draft3 ? 'B' : 'U');
|
||||
}
|
||||
|
||||
if (use_count)
|
||||
@ -16516,7 +16516,7 @@ class binary_writer
|
||||
{
|
||||
for (size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
|
||||
{
|
||||
oa->write_character(to_char_type((use_bjdata && bjdata_draft3) ? 'B' : 'U'));
|
||||
oa->write_character(to_char_type(bjdata_draft3 ? 'B' : 'U'));
|
||||
oa->write_character(j.m_data.m_value.binary->data()[i]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user