bitcoin/test/test_json.cpp
MacroFake f403531f97 Squashed 'src/univalue/' changes from a44caf65fe..6c19d050a9
6c19d050a9 Merge bitcoin-core/univalue-subtree#33: Add getInt<Integral>() helper
09e4a930fc Add getInt helper
10619e0d9a Merge bitcoin-core/univalue#32: refactor: include-what-you-use
431cdf5d27 refactor: use constexpr where appropriate
64fc881fa4 refactor: cleanup headers for iwyu
9c35bf38eb Merge bitcoin-core/univalue-subtree#30: doc: note that our API has diverged from upstream
09b65facb9 doc: note that our API has diverged from upstream

git-subtree-dir: src/univalue
git-subtree-split: 6c19d050a9bcb2be216121db0df57c930a9ee12e
2022-05-12 11:51:51 +02:00

27 lines
705 B
C++

// Test program that can be called by the JSON test suite at
// https://github.com/nst/JSONTestSuite.
//
// It reads JSON input from stdin and exits with code 0 if it can be parsed
// successfully. It also pretty prints the parsed JSON value to stdout.
#include <univalue.h>
#include <iostream>
#include <iterator>
#include <string>
using namespace std;
int main (int argc, char *argv[])
{
UniValue val;
if (val.read(string(istreambuf_iterator<char>(cin),
istreambuf_iterator<char>()))) {
cout << val.write(1 /* prettyIndent */, 4 /* indentLevel */) << endl;
return 0;
} else {
cerr << "JSON Parse Error." << endl;
return 1;
}
}