summaryrefslogtreecommitdiff
path: root/json.h
blob: 0e18911ff95de9809989d4e447272aa53083c411 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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