mirror of
https://github.com/halaxa/json-machine.git
synced 2025-01-17 13:08:16 +01:00
README
This commit is contained in:
parent
74159b7c06
commit
9255a78003
23
README.md
23
README.md
@ -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).
|
||||
|
Loading…
x
Reference in New Issue
Block a user