go
go copied to clipboard
UnmarshalFromString can't Unmarshal empty string.
for example:
func Test_customize_field_by_extension(t *testing.T) {
should := require.New(t)
cfg := jsoniter.Config{}.Froze()
cfg.RegisterExtension(&testExtension{})
obj := TestObject1{}
err := cfg.UnmarshalFromString(``, &obj)
should.Nil(err)
}
expect: err is nil, but err: "Read: unexpected value type: 0, error found in #0 byte of ...||..., bigger context ...||..."。
can't understand this error is a valid case?
An empty string is not valid json. The stdlib throws an error as well: unexpected end of JSON input.
can't understand this error is a valid case?
To answer your question, yes this error is valid.