You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"github.com/buger/jsonparser""fmt"
)
funcmain() {
body:= []byte(`["api",["Application programming interface"],["In computer programming, an application programming interface (API) is a set of subroutine definitions, protocols, and tools for building application software."],["https://en.wikipedia.org/wiki/Application_programming_interface"]]`)
jsonparser.ArrayEach(body, func(value []byte, dataType jsonparser.ValueType, offsetint, errerror) {
a, err:=jsonparser.GetString(value, "[0]")
iferr==nil {
fmt.Println(a)
} else {
fmt.Println(err)
}
})
}
The JSON comes directly from wikipedia. The first element of the array is not an array so I get why "Key path not found" is correct in that case but the other 3 are arrays with single element which is a string. I get "Unknown value type" for those.
The text was updated successfully, but these errors were encountered:
Here is a code to reproduce
The JSON comes directly from wikipedia. The first element of the array is not an array so I get why "Key path not found" is correct in that case but the other 3 are arrays with single element which is a string. I get "Unknown value type" for those.
The text was updated successfully, but these errors were encountered: