mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-27 11:21:02 +08:00
deprecate current Builders
This commit is contained in:
parent
1357cddf1e
commit
f3b3358a0e
@ -51,7 +51,7 @@ preserved.
|
|||||||
|
|
||||||
\code
|
\code
|
||||||
Json::Value root; // 'root' will contain the root value after parsing.
|
Json::Value root; // 'root' will contain the root value after parsing.
|
||||||
std::cin >> root; // Or see Json::CharReaderBuilder.
|
std::cin >> root;
|
||||||
|
|
||||||
// Get the value of the member of root named 'encoding', return 'UTF-8' if there is no
|
// Get the value of the member of root named 'encoding', return 'UTF-8' if there is no
|
||||||
// such member.
|
// such member.
|
||||||
@ -72,17 +72,21 @@ root["indent"]["length"] = getCurrentIndentLength();
|
|||||||
root["indent"]["use_space"] = getCurrentIndentUseSpace();
|
root["indent"]["use_space"] = getCurrentIndentUseSpace();
|
||||||
|
|
||||||
// If you like the defaults, you can insert directly into a stream.
|
// If you like the defaults, you can insert directly into a stream.
|
||||||
std::cout << root; // Or see Json::StreamWriterBuilder
|
std::cout << root;
|
||||||
|
// Of course, you can write to `std::ostringstream` if you prefer.
|
||||||
|
|
||||||
// If desired, remember to add a linefeed and flush.
|
// If desired, remember to add a linefeed and flush.
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
\section _advanced Advanced usage
|
\section _advanced Advanced usage
|
||||||
|
We are finalizing the new *Builder* API, which will be in versions
|
||||||
|
`1.4.0` and `0.8.0` when released. Until then, you may continue to
|
||||||
|
use the old API, include `Writer`, `Reader`, and `Feature`.
|
||||||
\code
|
\code
|
||||||
// Of course, you can write to `std::ostringstream` if you prefer. Or
|
|
||||||
// use `writeString()` for convenience, with a specialized builder.
|
// EXPERIMENTAL
|
||||||
|
// Or use `writeString()` for convenience, with a specialized builder.
|
||||||
Json::StreamWriterBuilder wbuilder;
|
Json::StreamWriterBuilder wbuilder;
|
||||||
builder.indentation_ = "\t";
|
builder.indentation_ = "\t";
|
||||||
std::string document = Json::writeString(root, wbuilder);
|
std::string document = Json::writeString(root, wbuilder);
|
||||||
@ -90,6 +94,7 @@ std::string document = Json::writeString(root, wbuilder);
|
|||||||
// You can also read into a particular sub-value.
|
// You can also read into a particular sub-value.
|
||||||
std::cin >> root["subtree"];
|
std::cin >> root["subtree"];
|
||||||
|
|
||||||
|
// EXPERIMENTAL
|
||||||
// Here we use a specialized Builder, discard comments, and
|
// Here we use a specialized Builder, discard comments, and
|
||||||
// record errors.
|
// record errors.
|
||||||
Json::CharReaderBuilder rbuilder;
|
Json::CharReaderBuilder rbuilder;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user