diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 9fbb4a119..146f71db5 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -725,6 +725,7 @@ class binary_writer @param[in] use_count whether to use '#' prefixes (optimized format) @param[in] use_type whether to use '$' prefixes (optimized format) @param[in] add_prefix whether prefixes need to be used for this value + @param[in] use_bjdata whether write in BJData format, default is false */ void write_ubjson(const BasicJsonType& j, const bool use_count, const bool use_type, const bool add_prefix = true, @@ -817,7 +818,7 @@ class binary_writer for (const auto& el : *j.m_value.array) { - write_ubjson(el, use_count, use_type, prefix_required); + write_ubjson(el, use_count, use_type, prefix_required, use_bjdata); } if (!use_count) @@ -909,7 +910,7 @@ class binary_writer oa->write_characters( reinterpret_cast(el.first.c_str()), el.first.size()); - write_ubjson(el.second, use_count, use_type, prefix_required); + write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata); } if (!use_count) @@ -1597,6 +1598,7 @@ class binary_writer /* @brief write a number to output input @param[in] n number of type @a NumberType + @param[in] use_bjdata whether write in BJData format, default is false @tparam NumberType the type of the number @tparam OutputIsLittleEndian Set to true if output data is required to be little endian diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 7e681ffbd..e60ac05e0 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3970,20 +3970,20 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec const bool use_type = false) { std::vector result; - to_bjdata(j, result, use_size, use_type, true); + to_bjdata(j, result, use_size, use_type); return result; } static void to_bjdata(const basic_json& j, detail::output_adapter o, const bool use_size = false, const bool use_type = false) { - binary_writer(o).write_ubjson(j, use_size, use_type, true); + binary_writer(o).write_ubjson(j, use_size, use_type, true, true); } static void to_bjdata(const basic_json& j, detail::output_adapter o, const bool use_size = false, const bool use_type = false) { - binary_writer(o).write_ubjson(j, use_size, use_type, true); + binary_writer(o).write_ubjson(j, use_size, use_type, true, true); } /// @brief create a BSON serialization of a given JSON value diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 1fe2228fd..0b30ab140 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -14549,6 +14549,7 @@ class binary_writer @param[in] use_count whether to use '#' prefixes (optimized format) @param[in] use_type whether to use '$' prefixes (optimized format) @param[in] add_prefix whether prefixes need to be used for this value + @param[in] use_bjdata whether write in BJData format, default is false */ void write_ubjson(const BasicJsonType& j, const bool use_count, const bool use_type, const bool add_prefix = true, @@ -14641,7 +14642,7 @@ class binary_writer for (const auto& el : *j.m_value.array) { - write_ubjson(el, use_count, use_type, prefix_required); + write_ubjson(el, use_count, use_type, prefix_required, use_bjdata); } if (!use_count) @@ -14733,7 +14734,7 @@ class binary_writer oa->write_characters( reinterpret_cast(el.first.c_str()), el.first.size()); - write_ubjson(el.second, use_count, use_type, prefix_required); + write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata); } if (!use_count) @@ -15421,6 +15422,7 @@ class binary_writer /* @brief write a number to output input @param[in] n number of type @a NumberType + @param[in] use_bjdata whether write in BJData format, default is false @tparam NumberType the type of the number @tparam OutputIsLittleEndian Set to true if output data is required to be little endian @@ -21741,20 +21743,20 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec const bool use_type = false) { std::vector result; - to_bjdata(j, result, use_size, use_type, true); + to_bjdata(j, result, use_size, use_type); return result; } static void to_bjdata(const basic_json& j, detail::output_adapter o, const bool use_size = false, const bool use_type = false) { - binary_writer(o).write_ubjson(j, use_size, use_type, true); + binary_writer(o).write_ubjson(j, use_size, use_type, true, true); } static void to_bjdata(const basic_json& j, detail::output_adapter o, const bool use_size = false, const bool use_type = false) { - binary_writer(o).write_ubjson(j, use_size, use_type, true); + binary_writer(o).write_ubjson(j, use_size, use_type, true, true); } /// @brief create a BSON serialization of a given JSON value