@@ -973,6 +973,8 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
973973
974974 std::string indentation = settings_[" indentation" ].asString ();
975975 std::string cs_str = settings_[" commentStyle" ].asString ();
976+ bool eyc = settings_[" enableYAMLCompatibility" ].asBool ();
977+ bool dnp = settings_[" dropNullPlaceholders" ].asBool ();
976978 CommentStyle::Enum cs = CommentStyle::All;
977979 if (cs_str == " All" ) {
978980 cs = CommentStyle::All;
@@ -982,10 +984,15 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
982984 return NULL ;
983985 }
984986 std::string colonSymbol = " : " ;
985- if (indentation.empty ()) {
987+ if (eyc) {
988+ colonSymbol = " : " ;
989+ } else if (indentation.empty ()) {
986990 colonSymbol = " :" ;
987991 }
988992 std::string nullSymbol = " null" ;
993+ if (dnp) {
994+ nullSymbol = " " ;
995+ }
989996 std::string endingLineFeedSymbol = " " ;
990997 return new BuiltStyledStreamWriter (
991998 indentation, cs,
@@ -996,6 +1003,8 @@ static void getValidWriterKeys(std::set<std::string>* valid_keys)
9961003 valid_keys->clear ();
9971004 valid_keys->insert (" indentation" );
9981005 valid_keys->insert (" commentStyle" );
1006+ valid_keys->insert (" enableYAMLCompatibility" );
1007+ valid_keys->insert (" dropNullPlaceholders" );
9991008}
10001009bool StreamWriterBuilder::validate (Json::Value* invalid) const
10011010{
@@ -1021,6 +1030,8 @@ void StreamWriterBuilder::setDefaults(Json::Value* settings)
10211030 // ! [StreamWriterBuilderDefaults]
10221031 (*settings)[" commentStyle" ] = " All" ;
10231032 (*settings)[" indentation" ] = " \t " ;
1033+ (*settings)[" enableYAMLCompatibility" ] = false ;
1034+ (*settings)[" dropNullPlaceholders" ] = false ;
10241035 // ! [StreamWriterBuilderDefaults]
10251036}
10261037
0 commit comments