JsonParser.cpp 429 B

1234567891011121314151617181920212223
  1. /*
  2. * malloc-free JSON parser for Arduino
  3. * Benoit Blanchon 2014
  4. * MIT License
  5. */
  6. #include "JsonParser.h"
  7. bool JsonParserBase::parse(char* jsonString)
  8. {
  9. buffer = jsonString;
  10. if (JSMN_SUCCESS != jsmn_parse(&parser, jsonString, tokens, maxTokenCount))
  11. return false;
  12. // Add null termination to each token
  13. for (int i = 1; i < parser.toknext; i++)
  14. {
  15. buffer[tokens[i].end] = 0;
  16. }
  17. return true;
  18. }