2014-07-03 13:58:08 +02:00
|
|
|
/*
|
|
|
|
* Arduino JSON library
|
|
|
|
* Benoit Blanchon 2014 - MIT License
|
|
|
|
*/
|
2014-01-11 15:05:35 +01:00
|
|
|
|
2014-07-03 13:58:08 +02:00
|
|
|
#pragma once
|
2014-01-11 15:05:35 +01:00
|
|
|
|
2014-07-16 13:26:11 +02:00
|
|
|
#include "JsonValue.h"
|
2014-07-18 22:40:50 +02:00
|
|
|
#include "JsonObjectIterator.h"
|
2014-07-16 13:26:11 +02:00
|
|
|
|
2014-07-03 14:00:51 +02:00
|
|
|
namespace ArduinoJson
|
2014-01-11 15:05:35 +01:00
|
|
|
{
|
2014-07-03 14:00:51 +02:00
|
|
|
namespace Parser
|
|
|
|
{
|
|
|
|
class JsonArray;
|
|
|
|
|
2014-07-19 12:44:27 +02:00
|
|
|
class JsonObject : public JsonToken
|
2014-07-03 14:00:51 +02:00
|
|
|
{
|
|
|
|
public:
|
2014-07-19 12:44:27 +02:00
|
|
|
JsonObject()
|
2014-07-18 16:46:01 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-19 12:44:27 +02:00
|
|
|
JsonObject(JsonToken token)
|
|
|
|
: JsonToken(token)
|
2014-07-18 15:43:20 +02:00
|
|
|
{
|
2014-07-19 12:44:27 +02:00
|
|
|
|
2014-07-18 15:43:20 +02:00
|
|
|
}
|
2014-01-11 15:05:35 +01:00
|
|
|
|
2014-07-16 13:41:00 +02:00
|
|
|
bool success()
|
|
|
|
{
|
2014-07-19 12:44:27 +02:00
|
|
|
return isObject();
|
2014-07-16 13:41:00 +02:00
|
|
|
}
|
|
|
|
|
2014-07-17 12:59:26 +02:00
|
|
|
JsonValue operator[](const char* key)
|
|
|
|
{
|
2014-07-18 15:43:20 +02:00
|
|
|
return getValue(key);
|
2014-07-17 12:59:26 +02:00
|
|
|
}
|
2014-07-16 13:26:11 +02:00
|
|
|
|
|
|
|
bool containsKey(const char* key)
|
|
|
|
{
|
2014-07-18 15:43:20 +02:00
|
|
|
return getValue(key).success();
|
2014-07-16 13:26:11 +02:00
|
|
|
}
|
2014-07-18 22:40:50 +02:00
|
|
|
|
|
|
|
JsonObjectIterator begin()
|
|
|
|
{
|
2014-07-19 12:44:27 +02:00
|
|
|
return firstChild();
|
2014-07-18 22:40:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
JsonObjectIterator end()
|
|
|
|
{
|
2014-07-19 12:44:27 +02:00
|
|
|
return nextSibling();
|
2014-07-18 22:40:50 +02:00
|
|
|
}
|
2014-07-16 13:26:11 +02:00
|
|
|
|
2014-07-16 13:53:56 +02:00
|
|
|
DEPRECATED JsonArray getArray(const char* key);
|
2014-07-16 13:26:11 +02:00
|
|
|
|
2014-07-16 13:53:56 +02:00
|
|
|
DEPRECATED bool getBool(const char* key)
|
2014-07-16 13:26:11 +02:00
|
|
|
{
|
2014-07-18 15:43:20 +02:00
|
|
|
return getValue(key);
|
2014-07-16 13:26:11 +02:00
|
|
|
}
|
|
|
|
|
2014-07-16 13:53:56 +02:00
|
|
|
DEPRECATED double getDouble(const char* key)
|
2014-07-16 13:26:11 +02:00
|
|
|
{
|
2014-07-18 15:43:20 +02:00
|
|
|
return getValue(key);
|
2014-07-16 13:26:11 +02:00
|
|
|
}
|
|
|
|
|
2014-07-18 16:46:01 +02:00
|
|
|
DEPRECATED JsonObject getHashTable(const char* key)
|
2014-07-16 13:26:11 +02:00
|
|
|
{
|
2014-07-18 15:43:20 +02:00
|
|
|
return getValue(key);
|
2014-07-16 13:26:11 +02:00
|
|
|
}
|
|
|
|
|
2014-07-16 13:53:56 +02:00
|
|
|
DEPRECATED long getLong(const char* key)
|
2014-07-16 13:26:11 +02:00
|
|
|
{
|
2014-07-18 15:43:20 +02:00
|
|
|
return getValue(key);
|
2014-07-16 13:26:11 +02:00
|
|
|
}
|
2014-01-13 19:46:53 +01:00
|
|
|
|
2014-07-16 13:53:56 +02:00
|
|
|
DEPRECATED char* getString(const char* key)
|
2014-07-16 13:26:11 +02:00
|
|
|
{
|
2014-07-18 15:43:20 +02:00
|
|
|
return getValue(key);
|
|
|
|
}
|
|
|
|
|
2014-07-18 16:46:01 +02:00
|
|
|
static JsonObject null()
|
2014-07-18 15:43:20 +02:00
|
|
|
{
|
2014-07-19 12:44:27 +02:00
|
|
|
return JsonObject(JsonToken::null());
|
2014-07-16 13:26:11 +02:00
|
|
|
}
|
2014-01-11 15:05:35 +01:00
|
|
|
|
2014-07-03 14:00:51 +02:00
|
|
|
private:
|
2014-01-11 15:05:35 +01:00
|
|
|
|
2014-07-18 15:43:20 +02:00
|
|
|
JsonValue getValue(const char* key);
|
2014-07-03 14:00:51 +02:00
|
|
|
};
|
2014-07-18 16:46:01 +02:00
|
|
|
|
|
|
|
typedef JsonObject JsonHashTable;
|
2014-07-03 14:00:51 +02:00
|
|
|
}
|
|
|
|
}
|