This repository was archived by the owner on Mar 17, 2025. It is now read-only.
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 {
5454
5555String FirebaseObject::getString (const String& path) const {
5656 JsonVariant variant = getJsonVariant (path);
57- if (!variant.is <const char *>()) {
57+ if (!variant.is <const char *>() || isNullString (path) ) {
5858 error_ = " failed to convert to string" ;
5959 return " " ;
6060 }
6161 return static_cast <const char *>(variant);
6262}
6363
64+ bool FirebaseObject::isNullString (const String& path) const {
65+ JsonVariant variant = getJsonVariant (path);
66+ return variant.is <const char *>() && variant.asString () == NULL ;
67+ }
68+
6469JsonVariant FirebaseObject::getJsonVariant (const String& path) const {
6570 String key (path);
6671 char * start = &key[0 ];
Original file line number Diff line number Diff line change @@ -43,6 +43,14 @@ class FirebaseObject {
4343 */
4444 bool getBool (const String& path = " " ) const ;
4545
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+
4654 /* *
4755 * Return the value as an int.
4856 * \param optional path in the JSON object.
You can’t perform that action at this time.
0 commit comments