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
In the below code (from http://play.golang.org/p/gX3MRTQyPA), it appears impossible to
predict program's output based solely on documentation of package encoding/json.
list := []int{-1}
err := json.Unmarshal([]byte("[1]"), &list)
if err != nil
log.Fatal(err)
}
log.Printf("%+v", list)
I can think of the following likely outcomes:
[-1]
[1]
[-1, 1]
Package encoding/json chooses [1] but I cannot seem to find a sentence that guarantees
it.
In contrast, relevant quote from package encoding/xml: "Unmarshal maps an XML
element to a slice by extending the length of the slice and mapping the element to the
newly created value."
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: