Skip to content

Added simple filtering and object property value checking #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 10, 2022

Conversation

Phando
Copy link

@Phando Phando commented Mar 4, 2022

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
Copy link

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
Copy link

github-actions bot commented Mar 4, 2022

Memory usage change @ 607acab

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<br>flash,%,examples/JSONArray<br>RAM for global variables,%,examples/JSONKitchenSink<br>flash,%,examples/JSONKitchenSink<br>RAM for global variables,%,examples/JSONObject<br>flash,%,examples/JSONObject<br>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
Copy link
Author

Phando commented Mar 4, 2022

CLA Signed, not showing though.

@per1234
Copy link
Contributor

per1234 commented Mar 4, 2022

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
Copy link
Author

Phando commented Mar 7, 2022

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

@per1234
Copy link
Contributor

per1234 commented Mar 7, 2022

The email address for the commits is:

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 <[email protected]>
Date:   Fri Mar 4 10:06:24 2022 -0800

    Updated the object filter implementation

commit 7ab7c5af463d2c0e7131f79f11fc21c0a8b84695
Author: Joe Andolina <[email protected]>
Date:   Fri Mar 4 09:44:19 2022 -0800

    Added cJSON_Duplicate to found items.

commit 1da99788176f26ed6db2a97e88a8038597b7da2b
Author: Joe Andolina <[email protected]>
Date:   Thu Mar 3 10:44:23 2022 -0800

    Added filtering and property comparison

commit 1dac1328e6beee7aa85828a6c890301ac0d91290
Author: Joe Andolina <[email protected]>
Date:   Wed Mar 2 11:06:08 2022 -0800

    More Work

commit 2058d1fdc6b2ee0c955e17e7c4fbfa7b9ed2d709
Author: Joe Andolina <[email protected]>
Date:   Wed Mar 2 10:55:36 2022 -0800

    Adding JSON helpers

Copy link
Contributor

@aentinger aentinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@aentinger aentinger merged commit 6235dc7 into arduino-libraries:master Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants