Skip to content

Commit 4d44309

Browse files
authored
Update README.md
1 parent 148fd82 commit 4d44309

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ You also can view API at [godoc.org](https://godoc.org/github.com/buger/jsonpars
7373

7474

7575
### **`Get`**
76-
```
76+
```go
7777
func Get(data []byte, keys ...string) (value []byte, dataType jsonparser.ValueType, offset int, err error)
7878
```
7979
Receives data structure, and key path to extract value from.
@@ -88,7 +88,7 @@ Accepts multiple keys to specify path to JSON value (in case of quering nested s
8888
If no keys are provided it will try to extract the closest JSON value (simple ones or object/array), useful for reading streams or arrays, see `ArrayEach` implementation.
8989

9090
### **`GetString`**
91-
```
91+
```go
9292
func GetString(data []byte, keys ...string) (val string, err error)
9393
```
9494
Returns strings properly handing escaped and unicode characters. Note that this will cause additional memory allocations.
@@ -109,7 +109,7 @@ Note that `unsafe` here means that your string will exist until GC will free und
109109

110110

111111
### **`GetBoolean`**, **`GetInt`** and **`GetFloat`**
112-
```
112+
```go
113113
func GetBoolean(data []byte, keys ...string) (val bool, err error)
114114

115115
func GetFloat(data []byte, keys ...string) (val float64, err error)
@@ -120,18 +120,18 @@ If you know the key type, you can use the helpers above.
120120
If key data type do not match, it will return error.
121121

122122
### **`ArrayEach`**
123-
```
123+
```go
124124
func ArrayEach(data []byte, cb func(value []byte, dataType jsonparser.ValueType, offset int, err error), keys ...string)
125125
```
126126
Needed for iterating arrays, accepts a callback function with the same return arguments as `Get`.
127127

128128
### **`KeyEach`**
129-
```
129+
```go
130130
func KeyEach(data []byte, cb func(idx int, value []byte, dataType jsonparser.ValueType, err error), paths ...[]string)
131131
```
132132
When you need to read multiple keys, and you do not afraid of low-level API `KeyEach` is your friend. It read payload only single time, and calls callback function once path is found. For example when you call multiple times `Get`, it has to process payload multiple times, each time you call it. Depending on payload `KeyEach` can be multiple times faster then `Get`. Path can use nested keys as well!
133133

134-
```
134+
```go
135135
paths := [][]string{
136136
[]string{"uuid"},
137137
[]string{"tz"},

0 commit comments

Comments
 (0)