JsonParserBase.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Arduino JSON library
  3. * Benoit Blanchon 2014 - MIT License
  4. */
  5. #pragma once
  6. #include "JsonArray.h"
  7. #include "JsonObject.h"
  8. namespace ArduinoJson
  9. {
  10. namespace Parser
  11. {
  12. // Base class for the JSON parser, in case you want to provide your own buffer
  13. class JsonParserBase
  14. {
  15. public:
  16. // Create a JSON parser using the provided buffer
  17. JsonParserBase(jsmntok_t* tokens, int maxTokens)
  18. : tokens(tokens), maxTokens(maxTokens)
  19. {
  20. }
  21. // Parse the JSON string and return a array
  22. //
  23. // The content of the string may be altered to add '\0' at the
  24. // end of string tokens
  25. JsonValue parse(char* json);
  26. // Obsolete: use parse() instead
  27. DEPRECATED JsonArray parseArray(char* json)
  28. {
  29. return parse(json);
  30. }
  31. // Obsolete: use parse() instead
  32. DEPRECATED JsonObject parseHashTable(char* json)
  33. {
  34. return parse(json);
  35. }
  36. private:
  37. jsmntok_t* tokens;
  38. int maxTokens;
  39. };
  40. }
  41. }