summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Hatch <jhatch@multitech.com>2021-03-11 08:21:22 -0600
committerJeff Hatch <jhatch@multitech.com>2021-03-11 08:21:22 -0600
commit962c6d0f5ce2579a6f3beeaa611659daeb4c2d44 (patch)
tree9d9ce237e4be9205f8e2450d4e57c4897991b57d
parentb171f5cb629c3123ec1adc0300ad63d297a77c25 (diff)
downloadjsparser-master.tar.gz
jsparser-master.tar.bz2
jsparser-master.zip
Update to support using jsoncpp versions later than 1.6.0HEAD0.4master
-rw-r--r--main.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index 761b507..76a5836 100644
--- a/main.cpp
+++ b/main.cpp
@@ -57,9 +57,17 @@ std::string handleIsOptions(const Json::Value& data);
int main(int argc, char** argv) {
Json::Value jInput;
- std::string sInput;
std::string sPath(parseOptions(argc, argv));
+#if defined(JSONCPP_VERSION_HEXA) && (JSONCPP_VERSION_HEXA > 0x010600) // > 1.6.0
+ Json::CharReaderBuilder builder;
+ builder.strictMode(&builder.settings_);
+ if (!Json::parseFromStream(builder, std::cin, &jInput, NULL)) {
+ fprintf(stderr, "bad json input\n");
+ return 1;
+ }
+#else
+ std::string sInput;
std::stringstream ss;
std::string line;
while (std::getline(std::cin, line)) {
@@ -77,7 +85,7 @@ int main(int argc, char** argv) {
fprintf(stderr, "bad json input\n");
return 1;
}
-
+#endif
printf("%s", get(sPath, jInput).c_str());
return 0;