Skip to content

Commit

Permalink
Update FirebaseJson.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Apr 20, 2022
1 parent 4651d67 commit f495568
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 185 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Arduino Google Sheet Client Library for ESP8266 and ESP32


Arduino Google Sheet Client Library for ESP8266 and ESP32 v1.0.2.
Arduino Google Sheet Client Library for ESP8266 and ESP32 v1.0.3.

This library allows devices to authenticate and communicate with Google Sheet APIs using the Service Account.

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ESP-Google-Sheet-Client",
"version": "1.0.2",
"version": "1.0.3",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "Arduino Google Sheet REST client library for ESP8266 and ESP32. This library allows devices to communicate with Google Sheet API to read, edit and delete the spreadsheets",
"repository": {
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=ESP-Google-Sheet-Client

version=1.0.2
version=1.0.3

author=Mobizt

Expand Down
6 changes: 3 additions & 3 deletions src/ESP_Google_Sheet_Client.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef ESP_GOOGLE_SHEET_CLIENT_VERSION
#define ESP_GOOGLE_SHEET_CLIENT_VERSION "1.0.1"
#define ESP_GOOGLE_SHEET_CLIENT_VERSION "1.0.3"
#endif

/**
* Google Sheet Client, ESP_Google_Sheet_Client.h v1.0.1
* Google Sheet Client, ESP_Google_Sheet_Client.h v1.0.3
*
* This library supports Espressif ESP8266 and ESP32 MCUs
*
* Created April 18, 2022
* Created April 20, 2022
*
* The MIT License (MIT)
* Copyright (c) 2022 K. Suwatchai (Mobizt)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ESPSigner/ESPSigner.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.4
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.5
*
* This library used RS256 for signing algorithm.
*
* The signed JWT token will be generated and exchanged with the access token in the final generating process.
*
* This library supports Espressif ESP8266 and ESP32
*
* Created April 18, 2022
* Created April 20, 2022
*
* The MIT License (MIT)
* Copyright (c) 2022 K. Suwatchai (Mobizt)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ESPSigner/ESPSigner.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.4
* Google's OAuth2.0 Access token Generation class, Signer.h version 1.1.5
*
* This library used RS256 for signing algorithm.
*
* The signed JWT token will be generated and exchanged with the access token in the final generating process.
*
* This library supports Espressif ESP8266 and ESP32
*
* Created April 18, 2022
* Created April 20, 2022
*
* The MIT License (MIT)
* Copyright (c) 2022 K. Suwatchai (Mobizt)
Expand Down
42 changes: 37 additions & 5 deletions src/lib/ESPSigner/json/FirebaseJson.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* FirebaseJson, version 2.6.16
* FirebaseJson, version 2.6.17
*
* The Easiest Arduino library to parse, create and edit JSON object using a relative path.
*
* Created April 18, 2022
* Created April 19, 2022
*
* Features
* - Using path to access node element in search style e.g. json.get(result,"a/b/c")
* - Serializing to writable objects e.g. String, C/C++ string, Client (WiFi and Ethernet), File and Hardware Serial.
* - Deserializing from const char, char array, string literal and stream e.g. Client (WiFi and Ethernet), File and
* - Serializing to writable objects e.g. String, C/C++ string, Clients (WiFi, Ethernet, and GSM), File and Hardware Serial.
* - Deserializing from const char, char array, string literal and stream e.g. Clients (WiFi, Ethernet, and GSM), File and
* Hardware Serial.
* - Use managed class, FirebaseJsonData to keep the deserialized result, which can be casted to any primitive data types.
*
Expand Down Expand Up @@ -77,7 +77,27 @@ void FirebaseJsonBase::mCopy(FirebaseJsonBase &other)
bool FirebaseJsonBase::setRaw(const char *raw)
{
mClear();
root = parse(raw);

if (raw)
{
size_t i = 0;
while (i < strlen(raw) && raw[i] == ' ')
{
i++;
}

if (raw[i] == '{' || raw[i] == '[')
{
this->root_type = (raw[i] == '{') ? Root_Type_JSON : Root_Type_JSONArray;
root = parse(raw);
}
else
{
this->root_type = Root_Type_Raw;
root = MB_JSON_CreateRaw(raw);
}
}

return root != NULL;
}

Expand Down Expand Up @@ -938,6 +958,11 @@ FirebaseJsonArray::FirebaseJsonArray(FirebaseJsonArray &other)

FirebaseJsonArray &FirebaseJsonArray::nAdd(MB_JSON *value)
{
if (root_type != Root_Type_JSONArray)
mClear();

root_type = Root_Type_JSONArray;

prepareRoot();

if (value == NULL)
Expand Down Expand Up @@ -974,6 +999,13 @@ bool FirebaseJsonArray::mGetIdx(FirebaseJsonData *result, int index, bool pretti

bool FirebaseJsonArray::mSetIdx(int index, MB_JSON *value)
{
if (root_type != Root_Type_JSONArray)
mClear();

root_type = Root_Type_JSONArray;

prepareRoot();

int size = MB_JSON_GetArraySize(root);
if (index < size)
return MB_JSON_ReplaceItemInArray(root, index, value);
Expand Down
Loading

0 comments on commit f495568

Please sign in to comment.