2014-01-11 15:05:35 +01:00
|
|
|
/*
|
|
|
|
* malloc-free JSON parser for Arduino
|
2014-01-11 16:41:18 +01:00
|
|
|
* Benoit Blanchon 2014 - MIT License
|
2014-01-11 15:05:35 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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
|
|
|
|
{
|
2014-01-11 22:55:00 +01:00
|
|
|
template <int N>
|
|
|
|
friend class JsonParser;
|
|
|
|
|
2014-01-11 15:05:35 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-01-11 15:15:52 +01:00
|
|
|
JsonArray getArray(int index);
|
2014-01-11 15:11:23 +01:00
|
|
|
JsonHashTable getHashTable(int index);
|
2014-01-11 15:15:52 +01:00
|
|
|
char* getString(int index);
|
|
|
|
|
2014-01-11 15:05:35 +01:00
|
|
|
private:
|
|
|
|
|
2014-01-11 16:41:18 +01:00
|
|
|
JsonArray(char* json, jsmntok_t* tokens);
|
2014-01-11 15:05:35 +01:00
|
|
|
jsmntok_t* getToken(int index);
|
|
|
|
};
|
|
|
|
|
2014-01-11 16:41:18 +01:00
|
|
|
#endif
|