dogecoin/src/univalue/test/test_json.cpp
Patrick Lodder d81d2329f2
Update univalue from bitcoin-core/univalue-subtree:bitcoin-fork
Merge commit 'd29583af8fa9536da33df679bd03f63d76c5d334' into 1.14.5-dev
2021-10-17 22:05:37 +02:00

25 lines
684 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 <iostream>
#include <string>
#include "univalue.h"
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;
}
}