22 #ifndef INCLUDE_OLA_WEB_JSON_H_
23 #define INCLUDE_OLA_WEB_JSON_H_
38 using std::stringstream;
48 virtual void ToString(ostream *output,
unsigned int indent)
const = 0;
51 void Indent(ostream *output,
unsigned int indent)
const {
52 *output << string(indent,
' ');
55 static const unsigned int INDENT = 2;
68 void ToString(ostream *output,
unsigned int)
const {
86 void ToString(ostream *output,
unsigned int)
const {
91 const unsigned int m_value;
104 void ToString(ostream *output,
unsigned int)
const {
122 void ToString(ostream *output,
unsigned int)
const {
123 *output << (m_value ?
"true" :
"false");
138 void ToString(ostream *output,
unsigned int)
const {
153 void ToString(ostream *output,
unsigned int)
const {
158 const string m_value;
172 void Add(
const string &key,
const string &value);
173 void Add(
const string &key,
const char *value);
174 void Add(
const string &key,
unsigned int i);
175 void Add(
const string &key,
int i);
176 void Add(
const string &key,
bool value);
177 void Add(
const string &key);
180 class JsonArray* AddArray(
const string &key);
182 void AddRaw(
const string &key,
const string &value);
184 void ToString(ostream *output,
unsigned int indent)
const;
187 typedef map<string, JsonValue*> MemberMap;
193 inline void FreeIfExists(
const string &key)
const;
205 : m_complex_type(
false) {
209 void Append(
const string &value) {
213 void Append(
const char *value) {
217 void Append(
unsigned int i) {
225 void Append(
bool value) {
235 m_values.push_back(obj);
236 m_complex_type =
true;
242 m_values.push_back(array);
243 m_complex_type =
true;
247 void AppendRaw(
const string &value) {
251 void ToString(ostream *output,
unsigned int indent)
const;
254 typedef vector<JsonValue*> ValuesVector;
255 ValuesVector m_values;
267 static string AsString(
const JsonValue &obj);
271 #endif // INCLUDE_OLA_WEB_JSON_H_