[DEPRECATED]🔥Firebase Arduino Client Library for ESP8266, ESP32 and RP2040 Pico. The complete, fast, secured and reliable Firebase Arduino client library that supports RTDB, Cloud Firestore, Firebase and Google Cloud Storage, Cloud Messaging and Cloud Functions for Firebase.
Hello,
I am using limitToLast with query. If I use json->toString(Serial, true) the output in serial is always correct (see screenshot below). However, when I use the code below to parse the json data, if I limit to more than 6 it doesn't work correctly anymore:
query.orderBy("$key"); query.limitToLast(10); Firebase.getJSON(fbdo, "/Devices/314", query); FirebaseJson *json = fbdo.to<FirebaseJson *>(); json->toString(Serial, true); size_t len = json->iteratorBegin(); Serial.print("LENGTH: "); Serial.println(len); if (len != 0) { for (int i = 0; i < len; i=i+3) { FirebaseJson::IteratorValue value; value = json->valueAt(i); const char* rawValue = value.value.c_str(); Serial.println(rawValue); } }
However, if I only print each third value (see the code below), it will print the correct values.
The code:
for (int i = 0; i < len; i=i+3) { FirebaseJson::IteratorValue value; value = json->valueAt(i); const char* rawTsStr2 = value.value.c_str(); Serial.println(rawTsStr2); }
The output:
[20.69,1699347325790] [85,1699347504159] [20.75,1699347600036] [20.75,1699347714305] [20.75,1699348216252] [6.69,1699348292049] [85,1699348716972] [5.81,1699350091850] [4.69,1699351891557] [6.75,1699353691672]
Why could this be happening? What could I try?
I don't understand why toString and every third (json->valueAt(i)) prints the correct values, but the code where I try to get each value (not array) doesn't work correctly after sixth value.
Many thanks
This is how json->toString(Serial, true) prints the data (this is correct):
In this screenshot you can see how it doesn't output the correct values after the sixth value:
When you use object and array iterator, it is about string search to extract all values which it can be the issue in case the key contains value in the old library version.
Hello, I am using limitToLast with query. If I use json->toString(Serial, true) the output in serial is always correct (see screenshot below). However, when I use the code below to parse the json data, if I limit to more than 6 it doesn't work correctly anymore:
query.orderBy("$key"); query.limitToLast(10); Firebase.getJSON(fbdo, "/Devices/314", query); FirebaseJson *json = fbdo.to<FirebaseJson *>(); json->toString(Serial, true); size_t len = json->iteratorBegin(); Serial.print("LENGTH: "); Serial.println(len); if (len != 0) { for (int i = 0; i < len; i=i+3) { FirebaseJson::IteratorValue value; value = json->valueAt(i); const char* rawValue = value.value.c_str(); Serial.println(rawValue); } }
However, if I only print each third value (see the code below), it will print the correct values. The code:
for (int i = 0; i < len; i=i+3) { FirebaseJson::IteratorValue value; value = json->valueAt(i); const char* rawTsStr2 = value.value.c_str(); Serial.println(rawTsStr2); }
The output:[20.69,1699347325790] [85,1699347504159] [20.75,1699347600036] [20.75,1699347714305] [20.75,1699348216252] [6.69,1699348292049] [85,1699348716972] [5.81,1699350091850] [4.69,1699351891557] [6.75,1699353691672]
Why could this be happening? What could I try? I don't understand why toString and every third (json->valueAt(i)) prints the correct values, but the code where I try to get each value (not array) doesn't work correctly after sixth value.Many thanks
This is how json->toString(Serial, true) prints the data (this is correct):
In this screenshot you can see how it doesn't output the correct values after the sixth value: