-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Labels
Description
by awreece:
What steps will reproduce the problem?
1. Marshal a struct that contains a nil []byte member.
For example,
type MyType struct {
Buf []byte
Ptr *int
Map map[string]string
}
bytes, _ := json.Marshal(&MyType{nil, nil, nil})
fmt.Println(string(bytes))
What is the expected output?
The member will be null. I expect to see:
j{"Buf":null,"Ptr":null,"Map":null}
What do you see instead? The member is empty:
{"Buf":"","Ptr":null,"Map":null}
(A subsequent json.Unmarshal confirms this, and produces a value equivalent to
MyType{make([]byte,0,0), nil, nil} )
Which compiler are you using (5g, 6g, 8g, gccgo)?
8g
Which operating system are you using?
Ubuntu 10.04
Which revision are you using? (hg identify)
253f02222ab0 tip
Attachments:
- json_test.go (1049 bytes)