jsoniter_invalid_test.go 512 B

123456789101112131415161718192021
  1. package jsoniter
  2. import (
  3. "testing"
  4. "github.com/json-iterator/go/require"
  5. )
  6. func Test_missing_object_end(t *testing.T) {
  7. should := require.New(t)
  8. type TestObject struct {
  9. Metric string `json:"metric"`
  10. Tags map[string]interface{} `json:"tags"`
  11. }
  12. obj := TestObject{}
  13. should.NotNil(UnmarshalFromString(`{"metric": "sys.777","tags": {"a":"123"}`, &obj))
  14. }
  15. func Test_missing_array_end(t *testing.T) {
  16. should := require.New(t)
  17. should.NotNil(UnmarshalFromString(`[1,2,3`, &[]int{}))
  18. }