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:
committed by
Kurt von Laven
parent
932c87f8e0
commit
4ce6cfff28
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user