Bitcoin Core
22.99.0
P2P Digital Currency
src
univalue
test
test_json.cpp
Go to the documentation of this file.
1
// Test program that can be called by the JSON test suite at
2
// https://github.com/nst/JSONTestSuite.
3
//
4
// It reads JSON input from stdin and exits with code 0 if it can be parsed
5
// successfully. It also pretty prints the parsed JSON value to stdout.
6
7
#include <iostream>
8
#include <string>
9
#include "
univalue.h
"
10
11
using namespace
std
;
12
13
int
main
(
int
argc,
char
*argv[])
14
{
15
UniValue
val;
16
if
(val.
read
(
string
(istreambuf_iterator<char>(cin),
17
istreambuf_iterator<char>()))) {
18
cout << val.
write
(1
/* prettyIndent */
, 4
/* indentLevel */
) << endl;
19
return
0;
20
}
else
{
21
cerr <<
"JSON Parse Error."
<< endl;
22
return
1;
23
}
24
}
UniValue::read
bool read(const char *raw, size_t len)
Definition:
univalue_read.cpp:259
UniValue::write
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
Definition:
univalue_write.cpp:28
UniValue
Definition:
univalue.h:17
univalue.h
main
int main(int argc, char *argv[])
Definition:
test_json.cpp:13
std
Definition:
setup_common.h:33
Generated on Fri Feb 18 2022 20:03:52 for Bitcoin Core by
1.8.17