diff --git a/decode_array.go b/decode_array.go index 297f2ee..7287524 100644 --- a/decode_array.go +++ b/decode_array.go @@ -76,6 +76,7 @@ func (dec *Decoder) decodeArrayNull(v interface{}) (int, error) { vv := reflect.ValueOf(v) vvt := vv.Type() if vvt.Kind() != reflect.Ptr || vvt.Elem().Kind() != reflect.Ptr { + dec.err = ErrUnmarshalPtrExpected return 0, dec.err } diff --git a/decode_bool.go b/decode_bool.go index 1dc304b..6a8cc4c 100644 --- a/decode_bool.go +++ b/decode_bool.go @@ -200,7 +200,6 @@ func (dec *Decoder) assertFalse() error { } // Add Values functions - // AddBool decodes the JSON value within an object or an array to a *bool. // If next key is neither null nor a JSON boolean, an InvalidUnmarshalError will be returned. // If next key is null, bool will be false. diff --git a/decode_bool_test.go b/decode_bool_test.go index 99a8342..5b5da2a 100644 --- a/decode_bool_test.go +++ b/decode_bool_test.go @@ -397,7 +397,7 @@ func TestDecoderBoolNull(t *testing.T) { }, { name: "null-error2", - json: "nual", + json: "nall", expectations: func(t *testing.T, v *bool, err error) { assert.NotNil(t, err, "err should be nil") assert.IsType(t, InvalidJSONError(""), err, "err should be of type InvalidJSONError") diff --git a/examples/http-benchmarks/gojay/main.go b/examples/http-benchmarks/gojay/main.go index 99b1eb3..9db30e3 100644 --- a/examples/http-benchmarks/gojay/main.go +++ b/examples/http-benchmarks/gojay/main.go @@ -156,3 +156,6 @@ func (v *ints) MarshalJSONArray(enc *gojay.Encoder) { func (v *ints) IsNil() bool { return v == nil || len(*v) == 0 } +func (v *ints) { + return v = v*2 +} \ No newline at end of file diff --git a/examples/http-json/main.go b/examples/http-json/main.go index 01bc443..1b33f3b 100644 --- a/examples/http-json/main.go +++ b/examples/http-json/main.go @@ -11,6 +11,7 @@ type message struct { bar string } + func (m *message) UnmarshalJSONObject(dec *gojay.Decoder, k string) error { switch k { case "foo": diff --git a/gojay/gojay.go b/gojay/gojay.go index e9358cb..2ad7f46 100644 --- a/gojay/gojay.go +++ b/gojay/gojay.go @@ -17,6 +17,7 @@ func main() { flag.Parse() options := codegen.NewOptionsWithFlagSet(flag.CommandLine) gen := codegen.NewGenerator(options) + // generate error if err := gen.Generate(); err != nil { log.Fatal(err) }