2014-07-22 20:28:59 +02:00
|
|
|
/*
|
|
|
|
* Arduino JSON library
|
|
|
|
* Benoit Blanchon 2014 - MIT License
|
|
|
|
*/
|
2014-07-18 15:43:20 +02:00
|
|
|
|
|
|
|
#include "JsonToken.h"
|
|
|
|
|
2014-07-19 12:44:27 +02:00
|
|
|
using namespace ArduinoJson::Parser;
|
2014-07-18 15:43:20 +02:00
|
|
|
|
2014-07-18 16:18:03 +02:00
|
|
|
JsonToken JsonToken::nextSibling() const
|
2014-07-18 15:43:20 +02:00
|
|
|
{
|
2014-07-22 20:28:59 +02:00
|
|
|
// start with current token
|
2014-07-18 15:43:20 +02:00
|
|
|
jsmntok_t* t = token;
|
2014-07-22 20:28:59 +02:00
|
|
|
|
|
|
|
// count the number of token to skip
|
2014-07-18 16:22:09 +02:00
|
|
|
int yetToVisit = 1;
|
|
|
|
|
2014-07-22 20:28:59 +02:00
|
|
|
// skip all nested tokens
|
2014-07-18 15:43:20 +02:00
|
|
|
while (yetToVisit)
|
|
|
|
{
|
2014-07-18 16:22:09 +02:00
|
|
|
yetToVisit += t->size - 1;
|
2014-07-18 15:43:20 +02:00
|
|
|
t++;
|
|
|
|
}
|
|
|
|
|
2014-07-22 20:28:59 +02:00
|
|
|
// build a JsonToken at the new location
|
2014-07-19 12:44:27 +02:00
|
|
|
return JsonToken(json, t);
|
2014-07-18 15:43:20 +02:00
|
|
|
}
|