1
0
mirror of synced 2025-12-30 03:01:36 -05:00

Add example for object filter on object.

There was already an example for using an object filter on an array.
Clarify that object filters can be used on objects as well and that the
result is an array, not an object.
This commit is contained in:
Kurt von Laven
2022-02-21 15:50:45 -08:00
committed by Kurt von Laven
parent 932c87f8e0
commit 4ce6cfff28

View File

@@ -366,4 +366,40 @@ For example, consider an array of objects named `fruits`.
]
```
The filter `fruits.*.name` returns the array `[ "apple", "orange", "pear" ]`
The filter `fruits.*.name` returns the array `[ "apple", "orange", "pear" ]`.
You may also use the `*` syntax on an object. For example, suppose you have an object named `vegetables`.
```json
{
"scallions":
{
"colors": ["green", "white", "red"],
"ediblePortions": ["roots", "stalks"],
},
"beets":
{
"colors": ["purple", "red", "gold", "white", "pink"],
"ediblePortions": ["roots", "stems", "leaves"],
},
"artichokes":
{
"colors": ["green", "purple", "red", "black"],
"ediblePortions": ["hearts", "stems", "leaves"],
},
}
```
The filter `vegetables.*.ediblePortions` could evaluate to:
```json
[
["roots", "stalks"],
["hearts", "stems", "leaves"],
["roots", "stems", "leaves"],
]
```
Since objects don't preserve order, the order of the output can not be guaranteed.