File tree Expand file tree Collapse file tree
include/nlohmann/detail/output Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -837,10 +837,10 @@ class binary_writer
837837 static std::size_t calc_bson_array_size (const typename BasicJsonType::array_t & value)
838838 {
839839 std::size_t embedded_document_size = 0ul ;
840-
840+ std:: size_t i = 0ull ;
841841 for (const auto & el : value)
842842 {
843- embedded_document_size += calc_bson_element_size (" " , el);
843+ embedded_document_size += calc_bson_element_size (std::to_string (i++) , el);
844844 }
845845
846846 return sizeof (std::int32_t ) + embedded_document_size + 1ul ;
@@ -854,9 +854,10 @@ class binary_writer
854854 write_bson_entry_header (name, 0x04 ); // array
855855 write_number<std::int32_t , true >(calc_bson_array_size (value));
856856
857+ std::size_t i = 0ull ;
857858 for (const auto & el : value)
858859 {
859- write_bson_element (" " , el);
860+ write_bson_element (std::to_string (i++) , el);
860861 }
861862
862863 oa->write_character (static_cast <CharType>(0x00 ));
Original file line number Diff line number Diff line change @@ -8994,10 +8994,10 @@ class binary_writer
89948994 static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value)
89958995 {
89968996 std::size_t embedded_document_size = 0ul;
8997-
8997+ std::size_t i = 0ull;
89988998 for (const auto& el : value)
89998999 {
9000- embedded_document_size += calc_bson_element_size("" , el);
9000+ embedded_document_size += calc_bson_element_size(std::to_string(i++) , el);
90019001 }
90029002
90039003 return sizeof(std::int32_t) + embedded_document_size + 1ul;
@@ -9011,9 +9011,10 @@ class binary_writer
90119011 write_bson_entry_header(name, 0x04); // array
90129012 write_number<std::int32_t, true>(calc_bson_array_size(value));
90139013
9014+ std::size_t i = 0ull;
90149015 for (const auto& el : value)
90159016 {
9016- write_bson_element("" , el);
9017+ write_bson_element(std::to_string(i++) , el);
90179018 }
90189019
90199020 oa->write_character(static_cast<CharType>(0x00));
Original file line number Diff line number Diff line change 44
55https://code.google.com/p/json-test-suite/downloads/detail?name=sample.zip&can=2&q=
66
7+ The file sample_cstr_keys.json has been copied from sample.json and modified by removing all U+0000 code points from all the keys.
8+
79## License
810
911Apache License Version 2.0
You can’t perform that action at this time.
0 commit comments