mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-27 11:21:02 +08:00
fix example in docs
This commit is contained in:
parent
c312dd5ef7
commit
37dde9d29d
@ -96,13 +96,13 @@ features without losing binary-compatibility.
|
|||||||
\code
|
\code
|
||||||
// For convenience, use `writeString()` with a specialized builder.
|
// For convenience, use `writeString()` with a specialized builder.
|
||||||
Json::StreamWriterBuilder wbuilder;
|
Json::StreamWriterBuilder wbuilder;
|
||||||
wbuilder.settings_["indentation"] = "\t"; // simple Json::Value
|
wbuilder["indentation"] = "\t";
|
||||||
std::string document = Json::writeString(wbuilder, root);
|
std::string document = Json::writeString(wbuilder, root);
|
||||||
|
|
||||||
// Here, using a specialized Builder, we discard comments and
|
// Here, using a specialized Builder, we discard comments and
|
||||||
// record errors as we parse.
|
// record errors as we parse.
|
||||||
Json::CharReaderBuilder rbuilder;
|
Json::CharReaderBuilder rbuilder;
|
||||||
rbuilder.settings_["collectComments"] = false; // simple Json::Value
|
rbuilder["collectComments"] = false;
|
||||||
std::string errs;
|
std::string errs;
|
||||||
bool ok = Json::parseFromStream(rbuilder, std::cin, &root, &errs);
|
bool ok = Json::parseFromStream(rbuilder, std::cin, &root, &errs);
|
||||||
\endcode
|
\endcode
|
||||||
|
@ -76,8 +76,8 @@ Usage:
|
|||||||
using namespace Json;
|
using namespace Json;
|
||||||
Value value = ...;
|
Value value = ...;
|
||||||
StreamWriterBuilder builder;
|
StreamWriterBuilder builder;
|
||||||
builder.settings_["commentStyle"] = "None";
|
builder["commentStyle"] = "None";
|
||||||
builder.settings_["indentation"] = " "; // or whatever you like
|
builder["indentation"] = " "; // or whatever you like
|
||||||
std::unique_ptr<Json::StreamWriter> writer(
|
std::unique_ptr<Json::StreamWriter> writer(
|
||||||
builder.newStreamWriter());
|
builder.newStreamWriter());
|
||||||
writer->write(value, &std::cout);
|
writer->write(value, &std::cout);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user