mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-13 06:44:12 +02:00
improve docs
including `writeString()`
This commit is contained in:
@@ -85,9 +85,8 @@ Json::StreamWriter::Builder builder;
|
||||
builder.withIndentation(" "); // or whatever you like
|
||||
|
||||
// Then build a StreamWriter.
|
||||
// (Of course, you can write to std::ostringstream if you prefer.)
|
||||
std::shared_ptr<Json::StreamWriter> writer(
|
||||
builder.newStreamWriter( &std::cout );
|
||||
builder.newStreamWriter( &std::cout ) );
|
||||
|
||||
// Make a new JSON document for the configuration. Preserve original comments.
|
||||
writer->write( root );
|
||||
@@ -95,6 +94,10 @@ writer->write( root );
|
||||
// If you like the defaults, you can insert directly into a stream.
|
||||
std::cout << root;
|
||||
|
||||
// Of course, you can write to `std::ostringstream` if you prefer. Or
|
||||
// use `writeString()` for convenience.
|
||||
std::string document = Json::writeString( root, builder );
|
||||
|
||||
// You can also read from a stream. This will put the contents of any JSON
|
||||
// stream at a particular sub-value, if you'd like.
|
||||
std::cin >> root["subtree"];
|
||||
|
Reference in New Issue
Block a user