...

Source file src/github.com/json-iterator/go/extra/private_fields_test.go

Documentation: github.com/json-iterator/go/extra

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

View as plain text