mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-18 04:52:22 +02:00
Added class JsonToken
This commit is contained in:
@ -7,8 +7,31 @@
|
||||
#include "JsonHashTable.h"
|
||||
|
||||
using namespace ArduinoJson::Parser;
|
||||
using namespace ArduinoJson::Internal;
|
||||
|
||||
DEPRECATED JsonHashTable JsonArray::getHashTable(int index)
|
||||
{
|
||||
return (JsonHashTable) (*this)[index];
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the token for the value at the specified index
|
||||
*/
|
||||
JsonValue JsonArray::operator[](int index)
|
||||
{
|
||||
// sanity check
|
||||
if (index < 0 || !token.isArray() || index >= token.size())
|
||||
return JsonValue::null();
|
||||
|
||||
// skip first token, it's the whole object
|
||||
JsonToken currentToken = token + 1;
|
||||
|
||||
// skip all tokens before the specified index
|
||||
for (int i = 0; i < index; i++)
|
||||
{
|
||||
// move forward: current + nested tokens
|
||||
currentToken += 1 + currentToken.nestedTokenCount();
|
||||
}
|
||||
|
||||
return JsonValue(json, currentToken);
|
||||
}
|
Reference in New Issue
Block a user