forked from mirror/gjson
mention GetBytes function
This commit is contained in:
parent
5fdbb97fe1
commit
95c6f92c50
13
README.md
13
README.md
|
@ -50,6 +50,9 @@ This will print:
|
||||||
Prichard
|
Prichard
|
||||||
```
|
```
|
||||||
|
|
||||||
|
*There also the [GetBytes](#working-with-bytes) function when working with JSON byte slices.*
|
||||||
|
|
||||||
|
|
||||||
## Path Syntax
|
## Path Syntax
|
||||||
|
|
||||||
A path is a series of keys separated by a dot.
|
A path is a series of keys separated by a dot.
|
||||||
|
@ -214,6 +217,16 @@ if !ok{
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Working with Bytes
|
||||||
|
|
||||||
|
If your JSON is contained a `[]byte` slice, there's the [GetBytes](https://godoc.org/github.com/tidwall/gjson#GetBytes) function. This is preferred over `Get(string(data), path)`.
|
||||||
|
|
||||||
|
```go
|
||||||
|
var data []byte = ...
|
||||||
|
res := gjson.GetBytes(data, path)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Performance
|
## Performance
|
||||||
|
|
||||||
Benchmarks of GJSON alongside [encoding/json](https://golang.org/pkg/encoding/json/),
|
Benchmarks of GJSON alongside [encoding/json](https://golang.org/pkg/encoding/json/),
|
||||||
|
|
Loading…
Reference in New Issue