mention GetBytes function

This commit is contained in:
Josh Baker 2016-10-28 09:07:48 -07:00 committed by GitHub
parent 5fdbb97fe1
commit 95c6f92c50
1 changed files with 14 additions and 1 deletions

View File

@ -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/),