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 property value comparison. #33

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.