diff --git a/src/boson/bson_archiver.hpp b/src/boson/bson_archiver.hpp index e590cb4..e036eea 100644 --- a/src/boson/bson_archiver.hpp +++ b/src/boson/bson_archiver.hpp @@ -394,7 +394,8 @@ class BSONOutputArchive : public cereal::OutputArchive { } else { // Set the key of this element to the name stored by the archiver. if (!_dotNotationMode || _embeddedNameStack.empty() || _arrayNestingLevel > 0) { - _bsonBuilder.key_view(_nextName); + if (!isNewNode) + _bsonBuilder.key_view(_nextName); } else { // If we are in dot notation mode and we're not nested in array, build the name of // this key.