JsonArray.h 757 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * malloc-free JSON parser for Arduino
  3. * Benoit Blanchon 2014
  4. * MIT License
  5. */
  6. #ifndef __JSONARRAY_H
  7. #define __JSONARRAY_H
  8. #include "JsonObjectBase.h"
  9. class JsonHashTable;
  10. class JsonArray : public JsonObjectBase
  11. {
  12. friend class JsonParserBase;
  13. friend class JsonHashTable;
  14. public:
  15. JsonArray() {}
  16. int getLength()
  17. {
  18. return tokens != 0 ? tokens[0].size : 0;
  19. }
  20. char* getString(int index)
  21. {
  22. jsmntok_t* token = getToken(index);
  23. return token != 0 ? json + token->start : 0;
  24. }
  25. JsonArray getArray(int index);
  26. JsonHashTable getHashTable(int index);
  27. private:
  28. JsonArray(char* json, jsmntok_t* tokens)
  29. : JsonObjectBase(json, tokens)
  30. {
  31. }
  32. jsmntok_t* getToken(int index);
  33. };
  34. #endif