rapidjson/example/pretty/pretty.cpp
miloyip@gmail.com 8f8e905306 Initial version (0.1)
git-svn-id: https://rapidjson.googlecode.com/svn/trunk@2 c5894555-1306-4e8d-425f-1f6f381ee07c
2011-11-18 17:01:23 +00:00

26 lines
647 B
C++

// JSON pretty formatting example
#include "rapidjson/reader.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/filestream.h"
using namespace rapidjson;
int main(int argc, char* argv[]) {
// Prepare reader and input stream.
Reader reader;
FileStream is(stdin);
// Prepare writer and output stream.
FileStream os(stdout);
PrettyWriter<FileStream> writer(os);
// JSON reader parse from the input stream and let writer generate the output.
if (!reader.Parse<0>(is, writer)) {
fprintf(stderr, "\nError(%u): %s\n", (unsigned)reader.GetErrorOffset(), reader.GetParseError());
return 1;
}
return 0;
}