private_fields_test.go 372 B

123456789101112131415161718
  1. package extra
  2. import (
  3. "github.com/json-iterator/go"
  4. "github.com/stretchr/testify/require"
  5. "testing"
  6. )
  7. func Test_private_fields(t *testing.T) {
  8. type TestObject struct {
  9. field1 string
  10. }
  11. SupportPrivateFields()
  12. should := require.New(t)
  13. obj := TestObject{}
  14. should.Nil(jsoniter.UnmarshalFromString(`{"field1":"Hello"}`, &obj))
  15. should.Equal("Hello", obj.field1)
  16. }