You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-15 22:50:24 +02:00
support private fields
This commit is contained in:
18
extra/private_fields_test.go
Normal file
18
extra/private_fields_test.go
Normal file
@ -0,0 +1,18 @@
|
||||
package extra
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user