int main(int argc, char* argv[]) { if (argc != 2) { fprintf(stderr, "filterkey key < input.json > output.json\n"); return 1; } // Prepare JSON reader and input stream. Reader reader; char readBuffer[65536]; FileReadStream is(stdin, readBuffer, sizeof(readBuffer)); // Prepare JSON writer and output stream. char writeBuffer[65536]; FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer)); Writer<FileWriteStream> writer(os); // Prepare Filter FilterKeyHandler<Writer<FileWriteStream> > filter(writer, argv[1], static_cast<SizeType>(strlen(argv[1]))); // JSON reader parse from the input stream, filter handler filters the events, and forward to writer. // i.e. the events flow is: reader -> filter -> writer if (!reader.Parse(is, filter)) { fprintf(stderr, "\nError(%u): %s\n", static_cast<unsigned>(reader.GetErrorOffset()), GetParseError_En(reader.GetParseErrorCode())); return 1; } return 0; }
int main(int, char*[]) { // Prepare JSON reader and input stream. Reader reader; FileStream is(stdin); // Prepare JSON writer and output stream. FileStream os(stdout); Writer<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; }
int main(int, char*[]) { // Prepare JSON reader and input stream. Reader reader; char readBuffer[65536]; FileReadStream is(stdin, readBuffer, sizeof(readBuffer)); // Prepare JSON writer and output stream. char writeBuffer[65536]; FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer)); Writer<FileWriteStream> writer(os); // JSON reader parse from the input stream and let writer generate the output. if (!reader.Parse(is, writer)) { fprintf(stderr, "\nError(%u): %s\n", static_cast<unsigned>(reader.GetErrorOffset()), GetParseError_En(reader.GetParseErrorCode())); return 1; } return 0; }