@@ -973,6 +973,8 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
973
973
974
974
std::string indentation = settings_[" indentation" ].asString ();
975
975
std::string cs_str = settings_[" commentStyle" ].asString ();
976
+ bool eyc = settings_[" enableYAMLCompatibility" ].asBool ();
977
+ bool dnp = settings_[" dropNullPlaceholders" ].asBool ();
976
978
CommentStyle::Enum cs = CommentStyle::All;
977
979
if (cs_str == " All" ) {
978
980
cs = CommentStyle::All;
@@ -982,10 +984,15 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
982
984
return NULL ;
983
985
}
984
986
std::string colonSymbol = " : " ;
985
- if (indentation.empty ()) {
987
+ if (eyc) {
988
+ colonSymbol = " : " ;
989
+ } else if (indentation.empty ()) {
986
990
colonSymbol = " :" ;
987
991
}
988
992
std::string nullSymbol = " null" ;
993
+ if (dnp) {
994
+ nullSymbol = " " ;
995
+ }
989
996
std::string endingLineFeedSymbol = " " ;
990
997
return new BuiltStyledStreamWriter (
991
998
indentation, cs,
@@ -996,6 +1003,8 @@ static void getValidWriterKeys(std::set<std::string>* valid_keys)
996
1003
valid_keys->clear ();
997
1004
valid_keys->insert (" indentation" );
998
1005
valid_keys->insert (" commentStyle" );
1006
+ valid_keys->insert (" enableYAMLCompatibility" );
1007
+ valid_keys->insert (" dropNullPlaceholders" );
999
1008
}
1000
1009
bool StreamWriterBuilder::validate (Json::Value* invalid) const
1001
1010
{
@@ -1021,6 +1030,8 @@ void StreamWriterBuilder::setDefaults(Json::Value* settings)
1021
1030
// ! [StreamWriterBuilderDefaults]
1022
1031
(*settings)[" commentStyle" ] = " All" ;
1023
1032
(*settings)[" indentation" ] = " \t " ;
1033
+ (*settings)[" enableYAMLCompatibility" ] = false ;
1034
+ (*settings)[" dropNullPlaceholders" ] = false ;
1024
1035
// ! [StreamWriterBuilderDefaults]
1025
1036
}
1026
1037
0 commit comments