The set function does not work
fahimbinkhair opened this issue · 0 comments
fahimbinkhair commented
data := []byte(
{
"person": {
"name": {
"first": "Leonid",
"last": "Bugaev",
"fullName": "Leonid Bugaev"
},
"github": {
"handle": "buger",
"followers": 109
},
"avatars": [
{ "url": "https://avatars1.githubusercontent.com/u/14009?v=3&s=460", "type": "thumbnail" }
]
},
"company": {
"name": "Acme"
}
}`)
x, err := jsonparser.Set(data, []byte("http://github.com"), "person", "avatars", "[0]", "url")
if err == nil {
log.Println(err.Error())
}
`
The code above gives error: runtime error: invalid memory address or nil pointer dereference