arduino-libraries / Arduino_JSON

Official JSON Library for Arduino
GNU Lesser General Public License v2.1
154 stars 60 forks source link

Added simple filtering and object property value checking #34

Closed Phando closed 2 years ago

Phando commented 2 years ago

Added two new functions to handle filtering (filter) and testing for object property value testing (hasPropertyEqual).

bool hasPropertyEqual(const char* key,  const char* value) const;  
bool hasPropertyEqual(const char* key,  const JSONVar& value) const;  
bool hasPropertyEqual(const String& key,  const String& value) const;  
bool hasPropertyEqual(const String& key,  const JSONVar& value) const;  

JSONVar filter(const char* key, const char* value) const;
JSONVar filter(const char* key, const JSONVar& value) const;
JSONVar filter(const String& key, const String& value) const;
JSONVar filter(const String& key, const JSONVar& value) const;

bool hasPropertyEqual returns true if the JSONVar has a property named key and that key is equal to value. myVar[key] != null && myVal[key] == value

JSONVar filter returns a JSONVar object containing objects who have properties named key and values matching value.

If no values are found it returns JSONVar(NULL, NULL) If one value is found it returns a JSONVar Object If multiple values are found it returns a JSONVar Array

CLAassistant commented 2 years ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Joe Andolina seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

github-actions[bot] commented 2 years ago

Memory usage change @ 607acab3f2195a9fb97b4d0986a6c06582e3c73c

Board flash % RAM for global variables %
arduino:avr:leonardo 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:avr:mega 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:avr:nano 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:avr:yun 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_edge:edge_control 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nano:nano33ble 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_portenta:envie_m4 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_portenta:envie_m7 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:megaavr:nona4809 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:megaavr:uno2018 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:sam:arduino_due_x_dbg 0 - 0 0.0 - 0.0 N/A N/A
arduino:samd:arduino_zero_edbg 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrzero 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:nano_33_iot 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table Board|examples/JSONArray
flash|%|examples/JSONArray
RAM for global variables|%|examples/JSONKitchenSink
flash|%|examples/JSONKitchenSink
RAM for global variables|%|examples/JSONObject
flash|%|examples/JSONObject
RAM for global variables|% -|-|-|-|-|-|-|-|-|-|-|-|- arduino:avr:leonardo|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:avr:mega|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:avr:nano|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:avr:yun|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:mbed_edge:edge_control|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:mbed_nano:nano33ble|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:mbed_nano:nanorp2040connect|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:mbed_portenta:envie_m4|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:mbed_portenta:envie_m7|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:megaavr:nona4809|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:megaavr:uno2018|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:sam:arduino_due_x_dbg|0|0.0|N/A|N/A|0|0.0|N/A|N/A|0|0.0|N/A|N/A arduino:samd:arduino_zero_edbg|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:mkrzero|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:nano_33_iot|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0
Click for full report CSV ``` Board,examples/JSONArray
flash,%,examples/JSONArray
RAM for global variables,%,examples/JSONKitchenSink
flash,%,examples/JSONKitchenSink
RAM for global variables,%,examples/JSONObject
flash,%,examples/JSONObject
RAM for global variables,% arduino:avr:leonardo,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:avr:mega,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:avr:nano,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:avr:yun,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:mbed_edge:edge_control,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:mbed_nano:nano33ble,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:mbed_nano:nanorp2040connect,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:mbed_portenta:envie_m4,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:mbed_portenta:envie_m7,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:megaavr:nona4809,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:megaavr:uno2018,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:sam:arduino_due_x_dbg,0,0.0,N/A,N/A,0,0.0,N/A,N/A,0,0.0,N/A,N/A arduino:samd:arduino_zero_edbg,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkrzero,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:nano_33_iot,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 ```
Phando commented 2 years ago

CLA Signed, not showing though.

per1234 commented 2 years ago

Hi @Phando. Thanks so much for your pull request!

The CLA check is done on the creator of the commits, not the creator of the pull request. The creator of the commits is determined by the GitHub user who has registered the email address specified in the commit metadata.

If you look at the commits, you can see that they are not associated with your GitHub account. This is caused by the way you have configured your local Git settings.

Please follow these instructions to resolve the issue:

https://docs.github.com/en/pull-requests/committing-changes-to-your-project/troubleshooting-commits/why-are-my-commits-linked-to-the-wrong-user#commits-are-not-linked-to-any-user

Hopefully the check will automatically pass once that has been done. If not, please comment here and we will investigate.

Phando commented 2 years ago

@per1234 It looks like all my submits are associated with my account.

per1234 commented 2 years ago

The email address for the commits is:

jandolina@jandolina-ltm.internal.salesforce.com

Have you added that email to your GitHub account according to these instructions?:

https://docs.github.com/en/pull-requests/committing-changes-to-your-project/troubleshooting-commits/why-are-my-commits-linked-to-the-wrong-user#commits-are-not-linked-to-any-user

$ git clone https://github.com/Phando/Arduino_JSON

$ cd Arduino_JSON/

$ git log -5
commit 607acab3f2195a9fb97b4d0986a6c06582e3c73c (HEAD -> master, origin/master, origin/HEAD)
Author: Joe Andolina <jandolina@jandolina-ltm.internal.salesforce.com>
Date:   Fri Mar 4 10:06:24 2022 -0800

    Updated the object filter implementation

commit 7ab7c5af463d2c0e7131f79f11fc21c0a8b84695
Author: Joe Andolina <jandolina@jandolina-ltm.internal.salesforce.com>
Date:   Fri Mar 4 09:44:19 2022 -0800

    Added cJSON_Duplicate to found items.

commit 1da99788176f26ed6db2a97e88a8038597b7da2b
Author: Joe Andolina <jandolina@jandolina-ltm.internal.salesforce.com>
Date:   Thu Mar 3 10:44:23 2022 -0800

    Added filtering and property comparison

commit 1dac1328e6beee7aa85828a6c890301ac0d91290
Author: Joe Andolina <jandolina@jandolina-ltm.internal.salesforce.com>
Date:   Wed Mar 2 11:06:08 2022 -0800

    More Work

commit 2058d1fdc6b2ee0c955e17e7c4fbfa7b9ed2d709
Author: Joe Andolina <jandolina@jandolina-ltm.internal.salesforce.com>
Date:   Wed Mar 2 10:55:36 2022 -0800

    Adding JSON helpers