Suppose we have following code:
result := []Foo{}
err := jsonparser.ArrayEach(data, func(value []byte, dataType jsonparser.ValueType, offset int, err error) {
if err != nil {
return
}
bars, err := extractBars(value)
if err != nil {
return
}
append(result, Foo{FieldOne: jsonparser.GetString(value, "target"), Bars: bars})
})
We have no options to stop iterate over data even if our function extractBars will return an error.
I think there are two possible ways of fixing this issue.
1. If we don't care about backward compatibility
Just change cb signature to cb func(value []byte, dataType ValueType, offset int, err error) error.
2. If we respect backward compatibility
Then we could add counterpart for both there functions and name these like IterArray, IterKeys or something like this.
P.S.: In both cases I could contribute with PR.
Suppose we have following code:
We have no options to stop iterate over
dataeven if our functionextractBarswill return an error.I think there are two possible ways of fixing this issue.
1. If we don't care about backward compatibility
Just change cb signature to
cb func(value []byte, dataType ValueType, offset int, err error) error.2. If we respect backward compatibility
Then we could add counterpart for both there functions and name these like
IterArray,IterKeysor something like this.P.S.: In both cases I could contribute with PR.