| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- /*
- * Arduino JSON library
- * Benoit Blanchon 2014 - MIT License
- */
- #pragma once
- #include "JsonValue.h"
- #include "JsonObjectIterator.h"
- namespace ArduinoJson
- {
- namespace Parser
- {
- class JsonArray;
- class JsonObject
- {
- public:
- JsonObject(char* json, Internal::JsonToken token)
- : json(json), token(token)
- {
- }
- JsonObject()
- : token(Internal::JsonToken::null())
- {
- }
- bool success()
- {
- return token.isObject();
- }
-
- JsonValue operator[](const char* key)
- {
- return getValue(key);
- }
- bool containsKey(const char* key)
- {
- return getValue(key).success();
- }
- JsonObjectIterator begin()
- {
- return JsonObjectIterator(json, token.firstChild());
- }
- JsonObjectIterator end()
- {
- return JsonObjectIterator(json, token.nextSibling());
- }
- DEPRECATED JsonArray getArray(const char* key);
- DEPRECATED bool getBool(const char* key)
- {
- return getValue(key);
- }
- DEPRECATED double getDouble(const char* key)
- {
- return getValue(key);
- }
- DEPRECATED JsonObject getHashTable(const char* key)
- {
- return getValue(key);
- }
- DEPRECATED long getLong(const char* key)
- {
- return getValue(key);
- }
- DEPRECATED char* getString(const char* key)
- {
- return getValue(key);
- }
- static JsonObject null()
- {
- return JsonObject();
- }
- private:
- char* json;
- Internal::JsonToken token;
- JsonValue getValue(const char* key);
- };
- typedef JsonObject JsonHashTable;
- }
- }
|