Files
ArduinoJson/JsonArray.h

50 lines
757 B
C
Raw Normal View History

2014-01-11 15:05:35 +01:00
/*
* malloc-free JSON parser for Arduino
* Benoit Blanchon 2014
* MIT License
*/
#ifndef __JSONARRAY_H
#define __JSONARRAY_H
#include "JsonObjectBase.h"
2014-01-11 15:11:23 +01:00
class JsonHashTable;
2014-01-11 15:05:35 +01:00
class JsonArray : public JsonObjectBase
{
friend class JsonParserBase;
friend class JsonHashTable;
public:
2014-01-11 15:11:23 +01:00
JsonArray() {}
2014-01-11 15:05:35 +01:00
2014-01-11 15:11:23 +01:00
int getLength()
2014-01-11 15:05:35 +01:00
{
2014-01-11 15:11:23 +01:00
return tokens != 0 ? tokens[0].size : 0;
2014-01-11 15:05:35 +01:00
}
char* getString(int index)
{
jsmntok_t* token = getToken(index);
return token != 0 ? json + token->start : 0;
}
2014-01-11 15:11:23 +01:00
JsonArray getArray(int index);
JsonHashTable getHashTable(int index);
2014-01-11 15:05:35 +01:00
private:
JsonArray(char* json, jsmntok_t* tokens)
: JsonObjectBase(json, tokens)
{
}
jsmntok_t* getToken(int index);
};
#endif