Skip to content

Commit 6451412

Browse files
committed
simplify basic docs
1 parent 66a8ba2 commit 6451412

2 files changed

Lines changed: 4 additions & 19 deletions

File tree

doc/jsoncpp.dox

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,8 @@ root["encoding"] = getCurrentEncoding();
7171
root["indent"]["length"] = getCurrentIndentLength();
7272
root["indent"]["use_space"] = getCurrentIndentUseSpace();
7373

74-
// (NEW IN 1.4.0)
75-
// To write into a stream with minimal memory overhead,
76-
// create a Builder for a StreamWriter.
77-
Json::StreamWriterBuilder builder;
78-
builder.indentation_ = " "; // or whatever you like
79-
80-
// Then build a StreamWriter.
81-
std::shared_ptr<Json::StreamWriter> writer(
82-
builder.newStreamWriter( &std::cout ) );
83-
84-
// Make a new JSON document for the configuration. Preserve original comments.
85-
writer->write( root );
86-
8774
// If you like the defaults, you can insert directly into a stream.
88-
std::cout << root;
75+
std::cout << root; // Or see StreamWriterBuilder.
8976

9077
// If desired, remember to add a linefeed and flush.
9178
std::cout << std::endl;
@@ -94,8 +81,7 @@ std::cout << std::endl;
9481
// use `writeString()` for convenience.
9582
std::string document = Json::writeString( root, builder );
9683

97-
// You can also read from a stream. This will put the contents of any JSON
98-
// stream at a particular sub-value, if you'd like.
84+
// You can also read into a particular sub-value.
9985
std::cin >> root["subtree"];
10086
\endcode
10187

include/json/writer.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ std::string writeString(Value const& root, StreamWriter::Factory const& factory)
8181
Value value = ...;
8282
StreamWriterBuilder builder;
8383
builder.cs_ = StreamWriter::CommentStyle::None;
84-
std::shared_ptr<StreamWriter> writer(
85-
builder.newStreamWriter(&std::cout));
84+
builder.indentation_ = " "; // or whatever you like
8685
writer->write(value);
8786
std::cout << std::endl; // add lf and flush
8887
\endcode
@@ -120,7 +119,7 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
120119
* OldCompressingStreamWriterBuilder b;
121120
* b.dropNullPlaceHolders_ = true; // etc.
122121
* StreamWriter* w = b.newStreamWriter(&std::cout);
123-
* w.write(value);
122+
* w->write(value);
124123
* delete w;
125124
* \endcode
126125
*/

0 commit comments

Comments
 (0)