Skip to content

Commit

Permalink
Fix FirebaseJson array parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Nov 11, 2019
1 parent c4a1c66 commit b90b76c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 33 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Firebase Realtime Database Arduino Library for ESP8266


Google's Firebase Realtime Database Arduino Library for ESP8266 v 2.6.6
Google's Firebase Realtime Database Arduino Library for ESP8266 v 2.6.7


This library supports ESP8266 MCU from Espressif. The following are platforms which library are also available.
Expand Down Expand Up @@ -48,7 +48,7 @@ This library supports ESP8266 MCU from Espressif. The following are platforms wh

## Changes from earlier version

For library v 2.6.6 (comes with FirebaseJson v 2.2.4) or later, FirebaseJson object will be used to handle JSON data instead of JSON string which, the following functions are affected:
For library v 2.6.7 (comes with FirebaseJson v 2.2.5) or later, FirebaseJson object will be used to handle JSON data instead of JSON string which, the following functions are affected:

getJson, setJson, pushJson, updateNode and updateNodeSilent.

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=Firebase ESP8266 Client

version=2.6.6
version=2.6.7

author=Mobizt

Expand Down
6 changes: 3 additions & 3 deletions src/FirebaseESP8266.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Google's Firebase Realtime Database Arduino Library for ESP8266, version 2.6.6
* Google's Firebase Realtime Database Arduino Library for ESP8266, version 2.6.7
*
* November 7, 2019
* November 12, 2019
*
* Feature Added:
*
* Feature Fixed:
* - BearSSL reserved rx buffer.
* - FirebaseJson array parsing.
*
*
* This library provides ESP8266 to perform REST API by GET PUT, POST, PATCH, DELETE data from/to with Google's Firebase database using get, set, update
Expand Down
6 changes: 3 additions & 3 deletions src/FirebaseESP8266.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Google's Firebase Realtime Database Arduino Library for ESP8266, version 2.6.6
* Google's Firebase Realtime Database Arduino Library for ESP8266, version 2.6.7
*
* November 7, 2019
* November 12, 2019
*
* Feature Added:
*
* Feature Fixed:
* - BearSSL reserved rx buffer.
* - FirebaseJson array parsing.
*
*
* This library provides ESP8266 to perform REST API by GET PUT, POST, PATCH, DELETE data from/to with Google's Firebase database using get, set, update
Expand Down
50 changes: 29 additions & 21 deletions src/FirebaseJson.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* FirebaseJson, version 2.2.4
* FirebaseJson, version 2.2.5
*
* The Easiest ESP8266/ESP32 Arduino library for parse, create and edit JSON object using relative path.
*
* October 27, 2019
* November 12, 2019
*
* Features
* - None recursive operations
Expand Down Expand Up @@ -293,7 +293,6 @@ void FirebaseJson::_addBool(const std::string &key, bool value)
_add(key.c_str(), _tr, key.length(), 6, false, true);
else
_add(key.c_str(), _fls, key.length(), 7, false, true);

}

void FirebaseJson::_addNull(const std::string &key)
Expand Down Expand Up @@ -675,25 +674,29 @@ bool FirebaseJson::_updateTkIndex(uint16_t index, int &depth, char *searchKey, i
}
else
{
for (int k = _el[i].oindex - 1; k < searchIndex; k++)
if (!_arrReplaced)
{
if (printMode == PRINT_MODE_PRETTY)
{
_jsonData._dbuf += _nl;
for (int j = 0; j < depth + 2; j++)
_jsonData._dbuf += _tab;
}
if (k == searchIndex - 1)
for (int k = _el[i].oindex - 1; k < searchIndex; k++)
{
if (_parseCompleted == (int)_pathTk.size())
_jsonData._dbuf += replace;
if (printMode == PRINT_MODE_PRETTY)
{
_jsonData._dbuf += _nl;
for (int j = 0; j < depth + 2; j++)
_jsonData._dbuf += _tab;
}
if (k == searchIndex - 1)
{
if (_parseCompleted == (int)_pathTk.size())
_jsonData._dbuf += replace;
else
_insertChilds(replace, printMode);
_arrReplaced = true;
}
else
_insertChilds(replace, printMode);
}
else
{
_jsonData._dbuf += _nll;
_jsonData._dbuf += _cm;
{
_jsonData._dbuf += _nll;
_jsonData._dbuf += _cm;
}
}
}
}
Expand Down Expand Up @@ -885,7 +888,7 @@ void FirebaseJson::_insertChilds(char *data, PRINT_MODE printMode)

void FirebaseJson::_addArrNodes(std::string &str, std::string &str2, int index, char *data, PRINT_MODE printMode)
{

int i = _getArrIndex(index);
str += _brk3;
if (printMode == PRINT_MODE_PRETTY)
Expand Down Expand Up @@ -1558,7 +1561,7 @@ void FirebaseJson::_compileToken(uint16_t &i, char *buf, int &depth, char *searc
_refToken = -1;
}

void FirebaseJson::_removeToken(uint16_t &i, char *buf, int &depth, char *searchKey, int searchIndex, PRINT_MODE printMode, char *replace, int refTokenIndex, bool removeTk)
void FirebaseJson::_removeToken(uint16_t &i, char *buf, int &depth, char *searchKey, int searchIndex, PRINT_MODE printMode, char *replace, int refTokenIndex, bool removeTk)
{
bool ncm = false;
tk_index_t tk;
Expand Down Expand Up @@ -1854,6 +1857,7 @@ void FirebaseJson::_parse(const char *path, PRINT_MODE printMode)
_parentIndex = -1;
_TkRefOk = false;
_parseCompleted = 0;
_arrReplaced = false;
_refTkIndex = -1;
_remTkIndex = -1;
_remFirstTk = false;
Expand Down Expand Up @@ -2155,6 +2159,7 @@ void FirebaseJson::_set(const char *path, const char *data)
_parentIndex = -1;
_TkRefOk = false;
_parseCompleted = 0;
_arrReplaced = false;
_refTkIndex = -1;
_remTkIndex = -1;
_remFirstTk = false;
Expand Down Expand Up @@ -2183,6 +2188,7 @@ void FirebaseJson::_set(const char *path, const char *data)
_parentIndex = -1;
_TkRefOk = false;
_parseCompleted = 0;
_arrReplaced = false;
_refTkIndex = -1;
_tokenMatch = false;
_paresRes = true;
Expand Down Expand Up @@ -2230,6 +2236,7 @@ bool FirebaseJson::remove(const String &path)
_parentIndex = -1;
_TkRefOk = false;
_parseCompleted = 0;
_arrReplaced = false;
_refTkIndex = -1;
_remTkIndex = -1;
_remFirstTk = false;
Expand Down Expand Up @@ -2257,6 +2264,7 @@ bool FirebaseJson::remove(const String &path)
_parentIndex = -1;
_TkRefOk = false;
_parseCompleted = 0;
_arrReplaced = false;
_refTkIndex = -1;
_tokenMatch = false;
_paresRes = true;
Expand Down
5 changes: 3 additions & 2 deletions src/FirebaseJson.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* FirebaseJson, version 2.2.4
* FirebaseJson, version 2.2.5
*
* The Easiest ESP8266/ESP32 Arduino library for parse, create and edit JSON object using relative path.
*
* October 27, 2019
* November 12, 2019
*
* Features
* - None recursive operations
Expand Down Expand Up @@ -556,6 +556,7 @@ class FirebaseJson
bool _remLastTk = false;
bool _collectTk = false;
bool _paresRes = false;
bool _arrReplaced = false;

char *_qt = nullptr;
char *_tab = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Firebase Realtime Database Arduino Library for ESP8266


Google's Firebase Realtime Database Arduino Library for ESP8266 v 2.6.6
Google's Firebase Realtime Database Arduino Library for ESP8266 v 2.6.7


## Global functions
Expand Down

0 comments on commit b90b76c

Please sign in to comment.