Files
ArduinoJson/JsonObjectBase.cpp

30 lines
564 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
*/
#include "JsonObjectBase.h"
int JsonObjectBase::getNestedTokenCount(jsmntok_t* token)
2014-01-11 15:05:35 +01:00
{
int count = 0;
for (int i = 0; i < token->size; i++)
2014-01-11 15:05:35 +01:00
{
count += 1 + getNestedTokenCount(token + 1 + i);
2014-01-11 15:05:35 +01:00
}
return count;
}
char* JsonObjectBase::getTokenString(jsmntok_t* token)
{
if (token->type != JSMN_PRIMITIVE && token->type != JSMN_STRING)
return 0;
// add null terminator to the string
json[token->end] = 0;
return json + token->start;
2014-01-11 15:05:35 +01:00
}