summaryrefslogtreecommitdiff
path: root/src/test_libjson.cc
blob: 03dc3bf1468aa94dffde0c656ad3e0ae529af3c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
}