diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-01-10 04:25:45 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-01-10 04:25:45 +0100 |
commit | ab7081676adf140cc8967c5ef49641b9a37bae2b (patch) | |
tree | 48c7da25061db1c0f486699bba384c2475680c70 /json.h | |
parent | 9abc3cad022da793ae16912d7feced8eef58be3d (diff) |
Add JSON parser/generator.
Diffstat (limited to 'json.h')
-rw-r--r-- | json.h | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -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 |