mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-17 20:42:24 +02:00
Added a verification of the token type before converting to string
This commit is contained in:
@ -6,14 +6,22 @@
|
||||
|
||||
#include "JsonObjectBase.h"
|
||||
|
||||
int JsonObjectBase::getNestedTokenCount(int tokenIndex)
|
||||
int JsonObjectBase::getNestedTokenCount(jsmntok_t* token)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < tokens[tokenIndex].size; i++)
|
||||
for (int i = 0; i < token->size; i++)
|
||||
{
|
||||
count += 1 + getNestedTokenCount(tokenIndex + 1 + i);
|
||||
count += 1 + getNestedTokenCount(token + 1 + i);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
char* JsonObjectBase::getTokenString(jsmntok_t* token)
|
||||
{
|
||||
if (token->type != JSMN_PRIMITIVE && token->type != JSMN_STRING)
|
||||
return 0;
|
||||
|
||||
return json + token->start;
|
||||
}
|
Reference in New Issue
Block a user