mirror of https://github.com/tidwall/gjson.git
additional example
This commit is contained in:
parent
d498de1770
commit
360ac81635
14
README.md
14
README.md
|
@ -48,11 +48,14 @@ This will print:
|
||||||
Prichard
|
Prichard
|
||||||
```
|
```
|
||||||
|
|
||||||
A path is a series of keys separated by a dot.
|
## Path Syntax
|
||||||
A key may contain special wildcard characters '\*' and '?'.
|
|
||||||
To access an array value use the index as the key.
|
A path is a series of keys separated by a dot.
|
||||||
|
A key may contain special wildcard characters '\*' and '?'.
|
||||||
|
To access an array value use the index as the key.
|
||||||
To get the number of elements in an array or to access a child path, use the '#' character.
|
To get the number of elements in an array or to access a child path, use the '#' character.
|
||||||
The dot and wildcard characters can be escaped with '\'.
|
The dot and wildcard characters can be escaped with '\'.
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"name": {"first": "Tom", "last": "Anderson"},
|
"name": {"first": "Tom", "last": "Anderson"},
|
||||||
|
@ -64,6 +67,7 @@ The dot and wildcard characters can be escaped with '\'.
|
||||||
{"first": "Roger", "last": "Craig"}
|
{"first": "Roger", "last": "Craig"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
"name.last" >> "Anderson"
|
"name.last" >> "Anderson"
|
||||||
"age" >> 37
|
"age" >> 37
|
||||||
"children.#" >> 3
|
"children.#" >> 3
|
||||||
|
@ -72,11 +76,9 @@ The dot and wildcard characters can be escaped with '\'.
|
||||||
"c?ildren.0" >> "Sara"
|
"c?ildren.0" >> "Sara"
|
||||||
"fav\.movie" >> "Deer Hunter"
|
"fav\.movie" >> "Deer Hunter"
|
||||||
"friends.#.first" >> [ "James", "Roger" ]
|
"friends.#.first" >> [ "James", "Roger" ]
|
||||||
|
"friends.1.last" >> "Craig"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Result Type
|
## Result Type
|
||||||
|
|
||||||
GJSON supports the json types `string`, `number`, `bool`, and `null`.
|
GJSON supports the json types `string`, `number`, `bool`, and `null`.
|
||||||
|
|
Loading…
Reference in New Issue