summaryrefslogtreecommitdiff
path: root/json.h
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-01-10 04:25:45 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-01-10 04:25:45 +0100
commitab7081676adf140cc8967c5ef49641b9a37bae2b (patch)
tree48c7da25061db1c0f486699bba384c2475680c70 /json.h
parent9abc3cad022da793ae16912d7feced8eef58be3d (diff)
Add JSON parser/generator.
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