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 db9135d commit e1652af
Show file tree
Hide file tree
Showing 8 changed files with 290 additions and 182 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Google OAuth2.0 Access Token generation Arduino Library v1.1.4
# Google OAuth2.0 Access Token generation Arduino Library v1.1.5


This is the library will create the OAuth2.0 access token used in the Google API's http request (REST).
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 Signer",
"version": "1.1.4",
"version": "1.1.5",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "The Google OAuth2.0 access token generation for Google REST API's http request.",
"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 Signer

version=1.1.4
version=1.1.5

author=Mobizt

Expand Down
4 changes: 2 additions & 2 deletions src/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/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/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 e1652af

Please sign in to comment.