mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Merged nestedTokenCount() and nextSibling()
This commit is contained in:
		| @@ -18,7 +18,7 @@ namespace ArduinoJson | ||||
|         { | ||||
|         public: | ||||
|  | ||||
|             JsonArrayIterator(char* json, Internal::JsonToken& token) | ||||
|             JsonArrayIterator(char* json, Internal::JsonToken token) | ||||
|                 : json(json), token(token) | ||||
|             { | ||||
|  | ||||
|   | ||||
| @@ -3,19 +3,17 @@ | ||||
|  | ||||
| using namespace ArduinoJson::Internal; | ||||
|  | ||||
| int JsonToken::nestedTokenCount() const | ||||
| JsonToken JsonToken::nextSibling() const | ||||
| { | ||||
|     jsmntok_t* t = token; | ||||
|     int yetToVisit = t->size; | ||||
|     int count = 0; | ||||
|  | ||||
|     while (yetToVisit) | ||||
|     { | ||||
|         count++; | ||||
|         t++; | ||||
|         yetToVisit--; | ||||
|         yetToVisit += t->size; | ||||
|     } | ||||
|  | ||||
|     return count; | ||||
|     return t + 1; | ||||
| } | ||||
| @@ -32,10 +32,7 @@ namespace ArduinoJson | ||||
|                 return JsonToken(token + 1); | ||||
|             } | ||||
|  | ||||
|             JsonToken nextSibling() const | ||||
|             { | ||||
|                 return JsonToken(token + 1 + nestedTokenCount()); | ||||
|             } | ||||
|             JsonToken nextSibling() const; | ||||
|  | ||||
|             bool operator!= (const JsonToken& other) | ||||
|             { | ||||
| @@ -79,9 +76,6 @@ namespace ArduinoJson | ||||
|  | ||||
|         private: | ||||
|             jsmntok_t* token; | ||||
|  | ||||
|             int nestedTokenCount() const; | ||||
|  | ||||
|         }; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -11,6 +11,16 @@ | ||||
| using namespace ArduinoJson::Parser; | ||||
| using namespace ArduinoJson::Internal; | ||||
|  | ||||
| JsonValue JsonValue::operator[](int index) | ||||
| { | ||||
|     return JsonArray(json, token)[index]; | ||||
| } | ||||
|  | ||||
| JsonValue JsonValue::operator[](const char* key) | ||||
| { | ||||
|     return JsonHashTable(json, token)[key]; | ||||
| } | ||||
|  | ||||
| JsonValue::operator bool() | ||||
| { | ||||
|     if (!token.isPrimitive()) return 0; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user