diff options
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 |