// without a major version bump.
/** Configuration of this builder.
Available settings (case-sensitive):
- - "commentStyle": "None", "Some", or "All"
+ - "commentStyle": "None" or "All"
- "indentation": "<anything>"
+ - "enableYAMLCompatibility": False or True
+ - slightly change the whitespace around colons
+ - "dropNullPlaceholders": False or True
+ - Drop the "null" string from the writer's output for nullValues.
+ Strictly speaking, this is not valid JSON. But when the output is being
+ fed to a browser's Javascript, it makes for smaller output and the
+ browser can handle the output just fine.
You can examine 'settings_` yourself
to see the defaults. You can also write and read them just like any
std::string indentation = settings_["indentation"].asString();
std::string cs_str = settings_["commentStyle"].asString();
+ bool eyc = settings_["enableYAMLCompatibility"].asBool();
+ bool dnp = settings_["dropNullPlaceholders"].asBool();
CommentStyle::Enum cs = CommentStyle::All;
if (cs_str == "All") {
cs = CommentStyle::All;
return NULL;
}
std::string colonSymbol = " : ";
- if (indentation.empty()) {
+ if (eyc) {
+ colonSymbol = ": ";
+ } else if (indentation.empty()) {
colonSymbol = ":";
}
std::string nullSymbol = "null";
+ if (dnp) {
+ nullSymbol = "";
+ }
std::string endingLineFeedSymbol = "";
return new BuiltStyledStreamWriter(
indentation, cs,
valid_keys->clear();
valid_keys->insert("indentation");
valid_keys->insert("commentStyle");
+ valid_keys->insert("enableYAMLCompatibility");
+ valid_keys->insert("dropNullPlaceholders");
}
bool StreamWriterBuilder::validate(Json::Value* invalid) const
{
//! [StreamWriterBuilderDefaults]
(*settings)["commentStyle"] = "All";
(*settings)["indentation"] = "\t";
+ (*settings)["enableYAMLCompatibility"] = false;
+ (*settings)["dropNullPlaceholders"] = false;
//! [StreamWriterBuilderDefaults]
}