1
0
mirror of https://github.com/halaxa/json-machine.git synced 2025-01-17 13:08:16 +01:00
This commit is contained in:
Filip Halaxa 2021-05-03 15:48:06 +02:00
parent 74159b7c06
commit 9255a78003

View File

@ -159,6 +159,29 @@ foreach ($fruits as $name => $data) {
> `results` at a time. It is always one item in memory at a time at the level/subtree
> you are currently iterating. Thus, the memory consumption is constant.
Json Pointer spec also allows using hyphen (`-`) instead of specific value of an array index. Json Machine interprets
this as a wildcard which matches any **array index** (not any object key). This enables you to iterate nested values in
arrays without loading the whole item.
Example:
```json
// fruitsArray.json
{
"results": [
{
"name": "apple",
"color": "red"
},
{
"name": "pear",
"color": "yellow"
}
]
}
```
To iterate over all colors of the fruits use json pointer `"/results/-/color"`.
<a name="json-pointer"></a>
#### What is Json Pointer?
It's a way of addressing one item in JSON document. See the [Json Pointer RFC 6901](https://tools.ietf.org/html/rfc6901).