github.com/bingoohuang/gg@v0.0.0-20240325092523-45da7dee9335/pkg/jsoni/extra/private_fields_test.go (about)

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