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
json unmarshal "null" to empty slice variable(etc: []string{} ) doesn't have err. But when marshal the variable, the value will be "null" instead of "[]"
#26866
Closed
Tron2016 opened this issue
Aug 8, 2018
· 1 comment
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
linux/amd64
What did you do?
ls := []string{}
if err := json.Unmarshal([]byte("null"), &ls); err != nil {
fmt.Println(err)
}
fmt.Println(ls)
if result, err := json.Marshal(ls); err != nil {
fmt.Println(err)
} else {
fmt.Println(string(result))
}
What did you expect to see?
output:
[]
[]
What did you see instead?
output
[]
null
The text was updated successfully, but these errors were encountered:
Tron2016
changed the title
json unmarshal "null" to slice verable(etx ) don't have err. But when mash the v
json unmarshal "null" to empty slice verable(etc: []string{} ) don't have err. But when mash the verable, the value will be "null" instead of "[]"
Aug 8, 2018
Tron2016
changed the title
json unmarshal "null" to empty slice verable(etc: []string{} ) don't have err. But when mash the verable, the value will be "null" instead of "[]"
json unmarshal "null" to empty slice variable(etc: []string{} ) doesn't have err. But when mash the variable, the value will be "null" instead of "[]"
Aug 8, 2018
Tron2016
changed the title
json unmarshal "null" to empty slice variable(etc: []string{} ) doesn't have err. But when mash the variable, the value will be "null" instead of "[]"
json unmarshal "null" to empty slice variable(etc: []string{} ) doesn't have err. But when mashal the variable, the value will be "null" instead of "[]"
Aug 8, 2018
Tron2016
changed the title
json unmarshal "null" to empty slice variable(etc: []string{} ) doesn't have err. But when mashal the variable, the value will be "null" instead of "[]"
json unmarshal "null" to empty slice variable(etc: []string{} ) doesn't have err. But when marshal the variable, the value will be "null" instead of "[]"
Aug 8, 2018
What version of Go are you using (
go version
)?go version go1.10.2
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?linux/amd64
What did you do?
What did you expect to see?
output:
[]
[]
What did you see instead?
output
[]
null
The text was updated successfully, but these errors were encountered: