From 6451412c994a3ad721b010533a6a103751c30fb1 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Mon, 9 Feb 2015 09:44:26 -0600 Subject: [PATCH] simplify basic docs --- doc/jsoncpp.dox | 18 ++---------------- include/json/writer.h | 5 ++--- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/doc/jsoncpp.dox b/doc/jsoncpp.dox index 1b246ef..5e34897 100644 --- a/doc/jsoncpp.dox +++ b/doc/jsoncpp.dox @@ -71,21 +71,8 @@ root["encoding"] = getCurrentEncoding(); root["indent"]["length"] = getCurrentIndentLength(); root["indent"]["use_space"] = getCurrentIndentUseSpace(); -// (NEW IN 1.4.0) -// To write into a stream with minimal memory overhead, -// create a Builder for a StreamWriter. -Json::StreamWriterBuilder builder; -builder.indentation_ = " "; // or whatever you like - -// Then build a StreamWriter. -std::shared_ptr writer( - builder.newStreamWriter( &std::cout ) ); - -// Make a new JSON document for the configuration. Preserve original comments. -writer->write( root ); - // If you like the defaults, you can insert directly into a stream. -std::cout << root; +std::cout << root; // Or see StreamWriterBuilder. // If desired, remember to add a linefeed and flush. std::cout << std::endl; @@ -94,8 +81,7 @@ std::cout << std::endl; // 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. +// You can also read into a particular sub-value. std::cin >> root["subtree"]; \endcode diff --git a/include/json/writer.h b/include/json/writer.h index 871287f..5dffbe0 100644 --- a/include/json/writer.h +++ b/include/json/writer.h @@ -81,8 +81,7 @@ Usage: Value value = ...; StreamWriterBuilder builder; builder.cs_ = StreamWriter::CommentStyle::None; - std::shared_ptr writer( - builder.newStreamWriter(&std::cout)); + builder.indentation_ = " "; // or whatever you like writer->write(value); std::cout << std::endl; // add lf and flush \endcode @@ -120,7 +119,7 @@ public: * OldCompressingStreamWriterBuilder b; * b.dropNullPlaceHolders_ = true; // etc. * StreamWriter* w = b.newStreamWriter(&std::cout); - * w.write(value); + * w->write(value); * delete w; * \endcode */