You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-08-13 22:12:45 +02:00
add test
This commit is contained in:
@@ -165,10 +165,11 @@ func Test_omit_empty(t *testing.T) {
|
|||||||
type TestObject struct {
|
type TestObject struct {
|
||||||
Field1 string `json:"field-1,omitempty"`
|
Field1 string `json:"field-1,omitempty"`
|
||||||
Field2 string `json:"field-2,omitempty"`
|
Field2 string `json:"field-2,omitempty"`
|
||||||
|
Field3 string `json:"field-3,omitempty"`
|
||||||
}
|
}
|
||||||
obj := TestObject{}
|
obj := TestObject{}
|
||||||
obj.Field2 = "hello"
|
obj.Field2 = "hello"
|
||||||
str, err := MarshalToString(&obj)
|
str, err := MarshalToString(&obj)
|
||||||
should.Nil(err)
|
should.Nil(err)
|
||||||
should.Equal(`{"field-2":"hello"}`, str)
|
should.Equal(`{"field-2":"hello"}`, str)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user