Files
ArduinoJson/JsonGeneratorTests/JsonObjectBase.h

44 lines
696 B
C
Raw Normal View History

2014-06-25 13:23:08 +02:00
/*
* Arduino JSON library
* Benoit Blanchon 2014 - MIT License
*/
#pragma once
#include "StringBuilder.h"
class JsonObjectBase
{
public:
protected:
2014-06-25 13:33:19 +02:00
enum ObjectType
2014-06-25 13:23:08 +02:00
{
JSON_STRING,
JSON_NUMBER,
JSON_BOOLEAN,
JSON_OBJECT,
2014-06-25 13:23:08 +02:00
};
2014-06-25 13:33:19 +02:00
union ObjectValue
2014-06-25 13:23:08 +02:00
{
const char* string;
double number;
bool boolean;
JsonObjectBase* object;
2014-06-25 13:23:08 +02:00
};
2014-06-25 13:33:19 +02:00
struct ObjectContainer
2014-06-25 13:23:08 +02:00
{
2014-06-25 13:33:19 +02:00
ObjectType type;
ObjectValue value;
2014-06-25 13:23:08 +02:00
};
2014-06-25 13:34:47 +02:00
void writeObjectTo(ObjectContainer& obj, StringBuilder& sb);
2014-06-25 13:34:47 +02:00
virtual void writeTo(StringBuilder& sb) = 0;
2014-06-25 13:23:08 +02:00
};