Skip to content

Commit 348cdde

Browse files
committed
readme fixes
1 parent 21e6d9e commit 348cdde

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
@@ -51,12 +51,12 @@ jsonparser.Get(data, "company")
5151

5252
// If the key doesn't exist it will throw an error
5353
var size int64
54-
if value, _, err := jsonparser.GetInt(data, "company", "size"); err != nil {
54+
if value, _, err := jsonparser.GetInt(data, "company", "size"); err == nil {
5555
size = value
5656
}
5757

5858
// You can use `ArrayEach` helper to iterate items
59-
jsonparser.ArrayEach(data, func(value []byte, dataType int, offset int, err error) (err error) {
59+
jsonparser.ArrayEach(data, func(value []byte, dataType jsonparser.ValueType, offset int, err error) {
6060
fmt.Println(jsonparser.Get(value, "url"))
6161
}, "person", "gravatar", "avatars")
6262
```
@@ -74,7 +74,7 @@ You also can view API at [godoc.org](https://godoc.org/github.com/buger/jsonpars
7474

7575
### **`Get`**
7676
```
77-
func Get(data []byte, keys ...string) (value []byte, dataType int, offset int, err error)
77+
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.
8080

@@ -94,7 +94,7 @@ func GetString(data []byte, keys ...string) (val string, err error)
9494
Returns strings properly handing escaped and unicode characters. Note that this will cause additional memory allocations.
9595

9696
### **`GetUnsafeString`**
97-
If you need string in your app, and ready to sacrifice with support of escaped symbols in favor of speed. It returns string mapped to exsting byte slice memory, without any allocations:
97+
If you need string in your app, and ready to sacrifice with support of escaped symbols in favor of speed. It returns string mapped to existing byte slice memory, without any allocations:
9898
```go
9999
s, _, := jsonparser.GetUnsafeString(data, "person", "name", "title")
100100
switch s {
@@ -105,7 +105,7 @@ switch s {
105105
...
106106
}
107107
```
108-
Note that `unsafe` here means that your string will exist until GC will free unrelying byte slice, for most of cases it means that you can use this string only in current context, and should not pass it anywhere externally: through channels or any other way.
108+
Note that `unsafe` here means that your string will exist until GC will free underlying byte slice, for most of cases it means that you can use this string only in current context, and should not pass it anywhere externally: through channels or any other way.
109109

110110

111111
### **`GetBoolean`**, **`GetInt`** and **`GetFloat`**
@@ -121,7 +121,7 @@ If key data type do not match, it will return error.
121121

122122
### **`ArrayEach`**
123123
```
124-
func ArrayEach(data []byte, cb func(value []byte, dataType int, offset int, err error), keys ...string)
124+
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

0 commit comments

Comments
 (0)