mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-04-21 08:18:57 +02:00

Rewerite and revert some code that this library can be built in pre-C++11 and C++11 env. Main Change List: 1. using -> typedef 2. not using auto & decltype 3. not using raw string literals 4. ..., other c++11 features will be chosen to compile, depending on env.
23 lines
494 B
C++
23 lines
494 B
C++
#include "json/json.h"
|
|
#include <iostream>
|
|
/** \brief Write the Value object to a stream.
|
|
* Example Usage:
|
|
* $g++ streamWrite.cpp -ljsoncpp -std=c++11 -o streamWrite
|
|
* $./streamWrite
|
|
* {
|
|
* "Age" : 20,
|
|
* "Name" : "robin"
|
|
* }
|
|
*/
|
|
int main() {
|
|
Json::Value root;
|
|
Json::StreamWriterBuilder builder;
|
|
Json::StreamWriter* writer(builder.newStreamWriter());
|
|
|
|
root["Name"] = "robin";
|
|
root["Age"] = 20;
|
|
writer->write(root, &std::cout);
|
|
delete writer;
|
|
return EXIT_SUCCESS;
|
|
}
|