Added wildcard key (*) for filters (closes #1309)

This commit is contained in:
Benoit Blanchon
2020-09-28 21:11:38 +02:00
parent 726f8be341
commit 8385d5fa3a
3 changed files with 11 additions and 1 deletions

View File

@ -24,6 +24,7 @@ v6.16.0 (2020-08-01)
* Added comparisons (`>`, `>=`, `==`, `!=`, `<`, and `<=`) between `JsonVariant`s
* Added string deduplication (issue #1303)
* Added `JsonString::operator!=`
* Added wildcard key (`*`) for filters (issue #1309)
* Set `ARDUINOJSON_DECODE_UNICODE` to `1` by default
* Fixed `copyArray()` not working with `String`, `ElementProxy`, and `MemberProxy`
* Fixed error `getOrAddElement is not a member of ElementProxy` (issue #1311)

View File

@ -214,6 +214,15 @@ TEST_CASE("Filtering") {
"{\"example\":{\"outcome\":42}}",
2 * JSON_OBJECT_SIZE(1) + 16
},
{
// wildcard
"{\"example\":{\"type\":\"int\",\"outcome\":42}}",
"{\"*\":{\"outcome\":true}}",
10,
DeserializationError::Ok,
"{\"example\":{\"outcome\":42}}",
2 * JSON_OBJECT_SIZE(1) + 16
},
{
// only the first element of array counts
"[1,2,3]",

View File

@ -33,7 +33,7 @@ class Filter {
if (_variant == true) // "true" means "allow recursively"
return *this;
else
return Filter(_variant[key]);
return Filter(_variant[key] | _variant["*"]);
}
private: