diff options
author | Patrick Simianer <p@simianer.de> | 2014-07-13 14:04:45 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-07-13 14:04:45 +0200 |
commit | 625269764ebbe8d0b566e6ef5fc26a6bccd4181d (patch) | |
tree | 70c54cb1dae9afddaefd7f0824427e95dd688081 /test_libjson.cc |
init
Diffstat (limited to 'test_libjson.cc')
-rw-r--r-- | test_libjson.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test_libjson.cc b/test_libjson.cc new file mode 100644 index 0000000..6b3e2a9 --- /dev/null +++ b/test_libjson.cc @@ -0,0 +1,44 @@ +#include <iostream> +#include <fstream> +#include <string> + +/* + * http://sourceforge.net/projects/libjson/ + * + */ +#include "libjson/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; +} + |