1
0
mirror of https://github.com/json-iterator/go.git synced 2025-04-26 11:42:56 +02:00
json-iterator/api_tests/decoder_test.go

18 lines
380 B
Go
Raw Normal View History

package test
import (
"bytes"
"github.com/stretchr/testify/require"
"testing"
2018-02-05 23:45:42 +08:00
"github.com/json-iterator/go"
)
func Test_disallowUnknownFields(t *testing.T) {
should := require.New(t)
type TestObject struct{}
var obj TestObject
2018-02-05 23:45:42 +08:00
decoder := jsoniter.NewDecoder(bytes.NewBufferString(`{"field1":100}`))
decoder.DisallowUnknownFields()
should.Error(decoder.Decode(&obj))
}