Skip to content

Commit

Permalink
Merge pull request #61 from blinker-iot/dev
Browse files Browse the repository at this point in the history
update json parse codes
  • Loading branch information
i3water authored Jun 19, 2018
2 parents 0326e69 + 8b5b1b2 commit 5fad205
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions src/Blinker/BlinkerApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3158,63 +3158,63 @@ class BlinkerApi
static_cast<Proto*>(this)->isParsed();
}
}
else {
}
else {
#if defined(ESP8266) || defined(ESP32)
String data1 = "{\"data\":" + _data + "}";
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(data1);
String data1 = "{\"data\":" + _data + "}";
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(data1);

if (!root.success()) {
return;
}
if (!root.success()) {
return;
}

String arrayData = root["data"][0];
String arrayData = root["data"][0];
#ifdef BLINKER_DEBUG_ALL
// BLINKER_LOG4("data1: ", data1, " arrayData: ", arrayData);
BLINKER_LOG2("_parse data: ", _data);
// BLINKER_LOG4("data1: ", data1, " arrayData: ", arrayData);
BLINKER_LOG2("_parse data: ", _data);
#endif
if (arrayData.length()) {
for (uint8_t a_num = 0; a_num < BLINKER_MAX_WIDGET_SIZE; a_num++) {
String array_data = root["data"][a_num];

// BLINKER_LOG2("array_data: ", array_data);

if(array_data.length()) {
DynamicJsonBuffer _jsonBuffer;
JsonObject& _array = _jsonBuffer.parseObject(array_data);

json_parse(_array);
timerManager(_array, true);
}
else {
return;
}
if (arrayData.length()) {
for (uint8_t a_num = 0; a_num < BLINKER_MAX_WIDGET_SIZE; a_num++) {
String array_data = root["data"][a_num];

// BLINKER_LOG2("array_data: ", array_data);

if(array_data.length()) {
DynamicJsonBuffer _jsonBuffer;
JsonObject& _array = _jsonBuffer.parseObject(array_data);

json_parse(_array);
timerManager(_array, true);
}
}
else {
JsonObject& root = jsonBuffer.parseObject(_data);

if (!root.success()) {
else {
return;
}
}
}
else {
JsonObject& root = jsonBuffer.parseObject(_data);

json_parse(root);
if (!root.success()) {
return;
}

json_parse(root);
}
#else
for (uint8_t bNum = 0; bNum < _bCount; bNum++) {
buttonParse(_Button[bNum]->getName(), _data);
}
for (uint8_t sNum = 0; sNum < _sCount; sNum++) {
slider(_Slider[sNum]->getName(), _data);
}
for (uint8_t kNum = 0; kNum < _tCount; kNum++) {
toggle(_Toggle[kNum]->getName(), _data);
}
for (uint8_t rgbNum = 0; rgbNum < _rgbCount; rgbNum++) {
rgb(_RGB[rgbNum]->getName(), R, _data);
}
#endif
for (uint8_t bNum = 0; bNum < _bCount; bNum++) {
buttonParse(_Button[bNum]->getName(), _data);
}
for (uint8_t sNum = 0; sNum < _sCount; sNum++) {
slider(_Slider[sNum]->getName(), _data);
}
for (uint8_t kNum = 0; kNum < _tCount; kNum++) {
toggle(_Toggle[kNum]->getName(), _data);
}
for (uint8_t rgbNum = 0; rgbNum < _rgbCount; rgbNum++) {
rgb(_RGB[rgbNum]->getName(), R, _data);
}
#endif
}
}

Expand Down

0 comments on commit 5fad205

Please sign in to comment.