summaryrefslogtreecommitdiff
path: root/src/test_libjson.cc
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-08-16 21:25:52 +0100
committerPatrick Simianer <p@simianer.de>2014-08-16 21:25:52 +0100
commit9a0859212de4d1304f9392fe910921227421c8c3 (patch)
tree1b1276312c83415d7d7d3838ce0347441b71951a /src/test_libjson.cc
parent3ba77e3474e39d7970784812f6851a726572f7c7 (diff)
cleanup
Diffstat (limited to 'src/test_libjson.cc')
-rw-r--r--src/test_libjson.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/test_libjson.cc b/src/test_libjson.cc
new file mode 100644
index 0000000..03dc3bf
--- /dev/null
+++ b/src/test_libjson.cc
@@ -0,0 +1,44 @@
+#include <iostream>
+#include <fstream>
+#include <string>
+
+/*
+ * http://sourceforge.net/projects/libjson/
+ *
+ */
+#include "libjson-7.6.1/libjson.h"
+
+using namespace std;
+
+
+void
+walk(const JSONNode & n)
+{
+ JSONNode::const_iterator it = n.begin();
+ while (it != n.end()){
+ if (it->type() == JSON_ARRAY || it->type() == JSON_NODE){
+ walk(*it);
+ }
+ string s = it->as_string();
+ if (s.size() >= 5) {
+ string t = s.substr(1, 4);
+ if (t == "Goal")
+ cerr << t << endl;
+ }
+ ++it;
+ }
+}
+
+int
+main(int argc, char** argv)
+{
+ ifstream ifs(argv[1]);
+ string json_str((istreambuf_iterator<char>(ifs)),
+ (istreambuf_iterator<char>()));
+
+ JSONNode n = libjson::parse(json_str);
+ walk(n);
+
+ return 0;
+}
+