From 9a0859212de4d1304f9392fe910921227421c8c3 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sat, 16 Aug 2014 21:25:52 +0100 Subject: cleanup --- src/test_sajson.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/test_sajson.cc (limited to 'src/test_sajson.cc') diff --git a/src/test_sajson.cc b/src/test_sajson.cc new file mode 100644 index 0000000..4081d43 --- /dev/null +++ b/src/test_sajson.cc @@ -0,0 +1,32 @@ +#include +#include +#include +#include + +/* + * https://github.com/chadaustin/sajson + * + */ +#include "sajson/include/sajson.h" + +using namespace std; + + +int +main(int argc, char** argv) +{ + ifstream ifs(argv[1]); + string json_str((istreambuf_iterator(ifs)), + (istreambuf_iterator())); + + const sajson::document& document = sajson::parse(sajson::literal(json_str.c_str())); + size_t index_a = document.get_root().find_object_key(sajson::literal("edges")); + const sajson::value& edges = document.get_root().get_object_value(index_a); + const sajson::value& last_edge = edges.get_array_element(edges.get_length()-1); + size_t index_r = last_edge.find_object_key(sajson::literal("rule")); + const sajson::value& r = last_edge.get_object_value(index_r); + cerr << r.as_string().substr(1, 4) << endl; + + return 0; +} + -- cgit v1.2.3