File tree Expand file tree Collapse file tree
docs/mkdocs/docs/api/basic_json
include/nlohmann/detail/output Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,10 +37,11 @@ The exact mapping and its limitations is described on a [dedicated page](../../f
3737
3838`use_type` (in)
3939: whether to add type annotations to container types (must be combined with `#!cpp use_size = true`); optional,
40+ `#!cpp false` by default.
4041
4142`version` (in)
42- : which version of BJData to use (see [draft 3](../../features/binary_formats/bjdata.md#draft-3-binary-format)); optional,
43- `#!cpp false ` by default.
43+ : which version of BJData to use (see [draft 3](../../features/binary_formats/bjdata.md#draft-3-binary-format));
44+ optional, `#!cpp bjdata_version_t::draft2 ` by default.
4445
4546## Return value
4647
Original file line number Diff line number Diff line change @@ -748,7 +748,7 @@ class binary_writer
748748 const bool use_type, const bool add_prefix = true ,
749749 const bool use_bjdata = false , const bjdata_version_t bjdata_version = bjdata_version_t ::draft2)
750750 {
751- const bool bjdata_draft3 = bjdata_version == bjdata_version_t ::draft3;
751+ const bool bjdata_draft3 = use_bjdata && bjdata_version == bjdata_version_t ::draft3;
752752
753753 switch (j.type ())
754754 {
@@ -857,11 +857,11 @@ class binary_writer
857857 oa->write_character (to_char_type (' [' ));
858858 }
859859
860- if (use_type && ((use_bjdata && bjdata_draft3) || !j.m_data .m_value .binary ->empty ()))
860+ if (use_type && (bjdata_draft3 || !j.m_data .m_value .binary ->empty ()))
861861 {
862862 JSON_ASSERT (use_count);
863863 oa->write_character (to_char_type (' $' ));
864- oa->write_character (use_bjdata && bjdata_draft3 ? ' B' : ' U' );
864+ oa->write_character (bjdata_draft3 ? ' B' : ' U' );
865865 }
866866
867867 if (use_count)
@@ -880,7 +880,7 @@ class binary_writer
880880 {
881881 for (size_t i = 0 ; i < j.m_data .m_value .binary ->size (); ++i)
882882 {
883- oa->write_character (to_char_type ((use_bjdata && bjdata_draft3) ? ' B' : ' U' ));
883+ oa->write_character (to_char_type (bjdata_draft3 ? ' B' : ' U' ));
884884 oa->write_character (j.m_data .m_value .binary ->data ()[i]);
885885 }
886886 }
Original file line number Diff line number Diff line change @@ -16416,7 +16416,7 @@ class binary_writer
1641616416 const bool use_type, const bool add_prefix = true,
1641716417 const bool use_bjdata = false, const bjdata_version_t bjdata_version = bjdata_version_t::draft2)
1641816418 {
16419- const bool bjdata_draft3 = bjdata_version == bjdata_version_t::draft3;
16419+ const bool bjdata_draft3 = use_bjdata && bjdata_version == bjdata_version_t::draft3;
1642016420
1642116421 switch (j.type())
1642216422 {
@@ -16525,11 +16525,11 @@ class binary_writer
1652516525 oa->write_character(to_char_type('['));
1652616526 }
1652716527
16528- if (use_type && ((use_bjdata && bjdata_draft3) || !j.m_data.m_value.binary->empty()))
16528+ if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
1652916529 {
1653016530 JSON_ASSERT(use_count);
1653116531 oa->write_character(to_char_type('$'));
16532- oa->write_character(use_bjdata && bjdata_draft3 ? 'B' : 'U');
16532+ oa->write_character(bjdata_draft3 ? 'B' : 'U');
1653316533 }
1653416534
1653516535 if (use_count)
@@ -16548,7 +16548,7 @@ class binary_writer
1654816548 {
1654916549 for (size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
1655016550 {
16551- oa->write_character(to_char_type((use_bjdata && bjdata_draft3) ? 'B' : 'U'));
16551+ oa->write_character(to_char_type(bjdata_draft3 ? 'B' : 'U'));
1655216552 oa->write_character(j.m_data.m_value.binary->data()[i]);
1655316553 }
1655416554 }
You can’t perform that action at this time.
0 commit comments