mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-13 06:44:12 +02:00
deprecate old Reader; separate Advanced Usage section
This commit is contained in:
@@ -51,7 +51,7 @@ preserved.
|
||||
|
||||
\code
|
||||
Json::Value root; // 'root' will contain the root value after parsing.
|
||||
std::cin >> root; // Or see CharReaderBuilder.
|
||||
std::cin >> root; // Or see Json::CharReaderBuilder.
|
||||
|
||||
// Get the value of the member of root named 'encoding', return 'UTF-8' if there is no
|
||||
// such member.
|
||||
@@ -72,17 +72,30 @@ root["indent"]["length"] = getCurrentIndentLength();
|
||||
root["indent"]["use_space"] = getCurrentIndentUseSpace();
|
||||
|
||||
// If you like the defaults, you can insert directly into a stream.
|
||||
std::cout << root; // Or see StreamWriterBuilder.
|
||||
std::cout << root; // Or see Json::StreamWriterBuilder
|
||||
|
||||
// If desired, remember to add a linefeed and flush.
|
||||
std::cout << std::endl;
|
||||
\endcode
|
||||
|
||||
\section _advanced Advanced usage
|
||||
|
||||
\code
|
||||
// Of course, you can write to `std::ostringstream` if you prefer. Or
|
||||
// use `writeString()` for convenience.
|
||||
std::string document = Json::writeString( root, builder );
|
||||
// use `writeString()` for convenience, with a specialized builder.
|
||||
Json::StreamWriterBuilder wbuilder;
|
||||
builder.indentation_ = "\t";
|
||||
std::string document = Json::writeString(root, wbuilder);
|
||||
|
||||
// You can also read into a particular sub-value.
|
||||
std::cin >> root["subtree"];
|
||||
|
||||
// Here we use a specialized Builder, discard comments, and
|
||||
// record errors.
|
||||
Json::CharReaderBuilder rbuilder;
|
||||
rbuilder.collectComments_ = false;
|
||||
std::string errs;
|
||||
Json::parseFromStream(rbuilder, std::cin, &root["subtree"], &errs);
|
||||
\endcode
|
||||
|
||||
\section _pbuild Build instructions
|
||||
|
Reference in New Issue
Block a user