File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -54,13 +54,18 @@ float FirebaseObject::getFloat(const String& path) const {
54
54
55
55
String FirebaseObject::getString (const String& path) const {
56
56
JsonVariant variant = getJsonVariant (path);
57
- if (!variant.is <const char *>()) {
57
+ if (!variant.is <const char *>() || isNullString (path) ) {
58
58
error_ = " failed to convert to string" ;
59
59
return " " ;
60
60
}
61
61
return static_cast <const char *>(variant);
62
62
}
63
63
64
+ bool FirebaseObject::isNullString (const String& path) const {
65
+ JsonVariant variant = getJsonVariant (path);
66
+ return variant.is <const char *>() && variant.asString () == NULL ;
67
+ }
68
+
64
69
JsonVariant FirebaseObject::getJsonVariant (const String& path) const {
65
70
String key (path);
66
71
char * start = &key[0 ];
Original file line number Diff line number Diff line change @@ -43,6 +43,14 @@ class FirebaseObject {
43
43
*/
44
44
bool getBool (const String& path = " " ) const ;
45
45
46
+ /* *
47
+ * Returns true if specified path is NULL string.
48
+ * Useful to detect tree deletions.
49
+ * \param optional path in the JSON object.
50
+ * \return result as a bool.
51
+ */
52
+ bool isNullString (const String& path = " " ) const ;
53
+
46
54
/* *
47
55
* Return the value as an int.
48
56
* \param optional path in the JSON object.
You can’t perform that action at this time.
0 commit comments