Added JsonArray::getLong() and JsonHashTable::getLong()

This commit is contained in:
Benoit Blanchon
2014-01-12 12:57:44 +01:00
parent b3647a7d91
commit 80c2cf3567
6 changed files with 28 additions and 5 deletions

View File

@ -6,6 +6,8 @@
#include "JsonObjectBase.h"
#include <stdlib.h> // for strtol
int JsonObjectBase::getNestedTokenCount(jsmntok_t* token)
{
int count = 0;
@ -18,7 +20,15 @@ int JsonObjectBase::getNestedTokenCount(jsmntok_t* token)
return count;
}
char* JsonObjectBase::getTokenString(jsmntok_t* token)
long JsonObjectBase::getLongFromToken(jsmntok_t* token)
{
if (token->type != JSMN_PRIMITIVE)
return 0;
return strtol(json + token->start, 0, 0);
}
char* JsonObjectBase::getStringFromToken(jsmntok_t* token)
{
if (token->type != JSMN_PRIMITIVE && token->type != JSMN_STRING)
return 0;