Don't add null terminator to each token.

This commit is contained in:
Benoit Blanchon
2014-01-11 22:39:28 +01:00
parent b53e0baadd
commit 0b485e95fa
2 changed files with 3 additions and 6 deletions

View File

@ -23,5 +23,8 @@ 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;
}

View File

@ -20,11 +20,5 @@ jsmntok_t* JsonParserBase::parse(char* jsonString)
if (JSMN_SUCCESS != jsmn_parse(&parser, jsonString, tokens, maxTokenCount))
return 0;
// Add null termination to each token
for (int i = 1; i < parser.toknext; i++)
{
jsonString[tokens[i].end] = 0;
}
return tokens;
}