summaryrefslogtreecommitdiff
path: root/json.h
diff options
context:
space:
mode:
Diffstat (limited to 'json.h')
-rw-r--r--json.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/json.h b/json.h
new file mode 100644
index 0000000..0e18911
--- /dev/null
+++ b/json.h
@@ -0,0 +1,32 @@
+#ifndef JSON_H
+#define JSON_H
+
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+
+#include <boost/variant.hpp>
+
+namespace JSON {
+ // TODO: Support null.
+ typedef boost::make_recursive_variant<
+ bool,
+ int,
+ float,
+ std::string,
+ std::vector<boost::recursive_variant_ >,
+ std::map<std::string, boost::recursive_variant_ >
+ >::type Value;
+
+ typedef std::vector<Value> Array;
+ typedef std::map<std::string, Value> Object;
+
+ //! Parse JSON string into value-tree.
+ bool parse(const std::string& s, Value& v);
+};
+
+//! Write JSON to stream.
+std::ostream& operator<<(std::ostream& s, const JSON::Value& v);
+
+#endif