summaryrefslogtreecommitdiff
path: root/src/test_picojson.cc
blob: cf3b621bd7aa2ae728306b8d4c98158372d04654 (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
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

/*
 * https://github.com/kazuho/picojson
 *
 */
#include "picojson/picojson.h"

using namespace std;


int
main(int argc, char** argv)
{
  ifstream ifs(argv[1]);
  string json_str((istreambuf_iterator<char>(ifs)),
                  (istreambuf_iterator<char>()));

  picojson::value v;
  istringstream iss(json_str);
  picojson::parse(v, iss);
  picojson::value::object& obj = v.get<picojson::object>();
  picojson::value::object& last_edge = obj["edges"].get<picojson::array>().back().get<picojson::object>();
  string s(last_edge["rule"].get<string>());
  cerr << s.substr(1, 4) << endl;

  return 0;
}