Files
ArduinoJson/JsonParser/JsonArray.h

93 lines
1.9 KiB
C
Raw Normal View History

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
#include "JsonValue.h"
#include "JsonArrayIterator.h"
2014-07-18 15:43:20 +02:00
#include "JsonToken.h"
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
{
2014-07-18 16:46:01 +02:00
class JsonObject;
2014-07-19 12:44:27 +02:00
class JsonArray : public JsonToken
2014-07-18 15:43:20 +02:00
{
2014-07-03 14:00:51 +02:00
public:
2014-01-11 15:05:35 +01:00
2014-07-19 12:44:27 +02:00
JsonArray()
{
2014-07-18 15:43:20 +02:00
}
2014-01-11 15:05:35 +01:00
2014-07-19 12:44:27 +02:00
JsonArray(JsonToken token)
: JsonToken(token)
{
}
2014-07-19 12:44:27 +02:00
bool success()
{
2014-07-19 12:44:27 +02:00
return isArray();
}
int size()
2014-07-03 14:00:51 +02:00
{
2014-07-19 12:44:27 +02:00
return isArray() ? JsonToken::size() : 0;
2014-07-03 14:00:51 +02:00
}
2014-01-11 15:05:35 +01:00
2014-07-19 12:44:27 +02:00
JsonValue operator[](int index)
{
return getValue(index);
}
JsonArrayIterator begin()
{
2014-07-19 12:44:27 +02:00
return firstChild();
}
JsonArrayIterator end()
{
2014-07-19 12:44:27 +02:00
return nextSibling();
}
DEPRECATED int getLength()
{
return size();
}
2014-07-16 13:53:56 +02:00
DEPRECATED JsonArray getArray(int index)
{
2014-07-19 12:44:27 +02:00
return getValue(index);
}
2014-07-16 13:53:56 +02:00
DEPRECATED bool getBool(int index)
{
2014-07-19 12:44:27 +02:00
return getValue(index);
}
2014-07-16 13:53:56 +02:00
DEPRECATED double getDouble(int index)
{
2014-07-19 12:44:27 +02:00
return getValue(index);
}
2014-07-18 16:46:01 +02:00
DEPRECATED JsonObject getHashTable(int index);
2014-07-16 13:53:56 +02:00
DEPRECATED long getLong(int index)
{
2014-07-19 12:44:27 +02:00
return getValue(index);
}
2014-07-16 13:53:56 +02:00
DEPRECATED char* getString(int index)
{
2014-07-19 12:44:27 +02:00
return getValue(index);
2014-07-18 15:43:20 +02:00
}
2014-07-03 14:00:51 +02:00
private:
2014-01-11 15:05:35 +01:00
2014-07-19 12:44:27 +02:00
JsonValue getValue(int index);
2014-07-03 14:00:51 +02:00
};
}
}