1
0
mirror of https://github.com/json-iterator/go.git synced 2025-04-04 21:34:16 +02:00
json-iterator/extra/private_fields_test.go

19 lines
372 B
Go
Raw Normal View History

2017-06-20 23:48:41 +08:00
package extra
import (
"github.com/json-iterator/go"
"github.com/stretchr/testify/require"
2017-06-21 00:26:18 +08:00
"testing"
2017-06-20 23:48:41 +08:00
)
func Test_private_fields(t *testing.T) {
type TestObject struct {
field1 string
}
SupportPrivateFields()
should := require.New(t)
obj := TestObject{}
should.Nil(jsoniter.UnmarshalFromString(`{"field1":"Hello"}`, &obj))
should.Equal("Hello", obj.field1)
}