Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 33363f7

Browse files
authored
Merge pull request #374 from kptdobe/issue/364
Firebase.readEvent() returns "type" instead "put" while getting data from Firebase
2 parents e197696 + 3195d23 commit 33363f7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/FirebaseArduino.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,13 @@ FirebaseObject FirebaseArduino::readEvent() {
179179
String event = client->readStringUntil('\n').substring(6);
180180
client->readStringUntil('\n'); // consume separator
181181
FirebaseObject obj = FirebaseObject(event.c_str());
182-
obj.getJsonVariant().asObject()["type"] = type.c_str();
182+
183+
// required to have a copy of the string but use a char[] format which is
184+
// the only supported format for JsonObject#set (it does not like the std::string of the test env)
185+
char *cstr = new char[type.length() + 1];
186+
strncpy(cstr, type.c_str(), type.length() + 1);
187+
obj.getJsonVariant().as<JsonObject&>().set("type", cstr);
188+
delete[] cstr;
183189
return obj;
184190
}
185191

0 commit comments

Comments
 (0)