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
This comes from trying to decode real facebook response, but this is a minimal test case:
package main
import (
"encoding/json"
"fmt"
"github.com/huandu/facebook"
)
type Actions2 struct {
Foo int
}
type Foo struct {
Actions2 *Actions2
Comment int
}
func testDecode(sJson string) {
var result facebook.Result
err := json.Unmarshal([]byte(sJson), &result)
if err != nil {
fmt.Printf("json.Unmarshal() failed with %q\n", err)
return
}
var v Foo
err = result.Decode(&v)
if err != nil {
fmt.Printf("result.Decode() failed with %q\n", err)
return
}
fmt.Printf("testDocode: ok!\n")
}
func main() {
// this is ok
sJson := `{
"comment": 5
}`
testDecode(sJson)
// this fails
sJson = `{
"actions2": null,
"comment": 5
}`
testDecode(sJson)
}
The code fails with error reflect: call of reflect.Value.Type on zero Value when trying to decode actions2 when "actions2" field exists in json but is set to "null".
It doesn't happen when "actions2" field is completely missing.
The text was updated successfully, but these errors were encountered:
This comes from trying to decode real facebook response, but this is a minimal test case:
The code fails with error
reflect: call of reflect.Value.Type on zero Value
when trying to decode actions2 when "actions2" field exists in json but is set to "null".It doesn't happen when "actions2" field is completely missing.
The text was updated successfully, but these errors were encountered: