Skip to content

Commit

Permalink
Merge pull request #374 from kptdobe/issue/364
Browse files Browse the repository at this point in the history
Firebase.readEvent() returns "type" instead "put" while getting data from Firebase
  • Loading branch information
kotl committed Aug 15, 2018
2 parents e197696 + 3195d23 commit 33363f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/FirebaseArduino.cpp
Expand Up @@ -179,7 +179,13 @@ FirebaseObject FirebaseArduino::readEvent() {
String event = client->readStringUntil('\n').substring(6);
client->readStringUntil('\n'); // consume separator
FirebaseObject obj = FirebaseObject(event.c_str());
obj.getJsonVariant().asObject()["type"] = type.c_str();

// required to have a copy of the string but use a char[] format which is
// the only supported format for JsonObject#set (it does not like the std::string of the test env)
char *cstr = new char[type.length() + 1];
strncpy(cstr, type.c_str(), type.length() + 1);
obj.getJsonVariant().as<JsonObject&>().set("type", cstr);
delete[] cstr;
return obj;
}

Expand Down

0 comments on commit 33363f7

Please sign in to comment.