This commit adds the Escape function for escaping a path
component, making it possible to directly querying keys that have
special characters like dots.
```
json := `{
"user":{
"first.name": "Janet",
"last.name": "Prichard"
}
}`
user := gjson.Get(json, "user")
println(user.Get(gjson.Escape("first.name")).String())
println(user.Get(gjson.Escape("last.name")).String())
// Output:
// Janet
// Prichard
```
See #333
This commit adds the "@dig" modifier, which allows for searching
for values in deep or arbitrarily nested json documents
For example, using the following json:
```
{ "something": {
"anything": {
"abcdefg": {
"finally": {
"important": {
"secret": "password"
}
}
}
}
}
}
```
```
@dig:secret -> ["password"]
```
See #130
This commit fixes an issue with ~false where the it's value was
simply the opposite of ~true. Now ~false explicitly checks for
false-ish values.
Also added ~null and ~* for testing null-ish and non-existent
values.
see #327
The only purpose of using the built-in Go was to encode json
strings that had unicode or needed to escaped.
This commit adds the new function `AppendJSONString` which allows
for appending strings as their json representation to a byte
slice.
It's about 2x faster than using json.Marshal.
The new "@group" modifier allows for grouping arrays of objects.
For example, using the "@group" modifier on the following json...
{"id":["123","456","789"],"val":[2,1]}
will results in...
[{"id":"123","val":2},{"id":"456","val":1},{"id":"789"}]
This commit adds a two new functions of the Result type:
- Result.Path: Returns the original path of a `Result` that was
returned from a simple `Get` operation.
- Result.Paths: Returns the original paths of a `Result` that was
returned from a `Get` operation with a query.
See issue #206 for more details
The "@keys" and "@values" modifiers converts an object into an
array of its keys or values respectively.
Take this json for example:
{"first":"Tom","last":"Smith"}
@keys -> ["first","last"]
@values -> ["Tom","Smith"]
This feature was requested in #161.