From 48a10a728bc5045530e0d1039383bf538188beb8 Mon Sep 17 00:00:00 2001 From: Pouya1364 Date: Tue, 21 Jul 2020 19:07:03 +0800 Subject: [PATCH 1/6] change decoder function --- decode_array.go | 1 + examples/http-json/main.go | 1 + 2 files changed, 2 insertions(+) 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/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": From c56b678d06f2b1885ed06bba2f0de7b5addcab0d Mon Sep 17 00:00:00 2001 From: Pouya1364 Date: Thu, 23 Jul 2020 10:31:46 +0800 Subject: [PATCH 2/6] addsmall function to return V --- examples/http-benchmarks/gojay/main.go | 3 +++ 1 file changed, 3 insertions(+) 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 From 01b05018f54d06e6056d03c0bb489aa7eec04f62 Mon Sep 17 00:00:00 2001 From: Pouya1364 Date: Mon, 3 Aug 2020 14:50:41 +0800 Subject: [PATCH 3/6] Update gojay.go --- gojay/gojay.go | 1 + 1 file changed, 1 insertion(+) 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) } From 6f815f38e6a3fe77ec8b771f1eabb5ec103ba002 Mon Sep 17 00:00:00 2001 From: Pouya1364 Date: Thu, 6 Aug 2020 16:59:09 +0800 Subject: [PATCH 4/6] Update decode_bool.go --- decode_bool.go | 1 - 1 file changed, 1 deletion(-) 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. From 6340fabb390105ddc447e9c095a05427ec0b0197 Mon Sep 17 00:00:00 2001 From: Pouya1364 Date: Sat, 8 Aug 2020 18:52:24 +0800 Subject: [PATCH 5/6] Update decode_bool_test.go chnge error code --- decode_bool_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decode_bool_test.go b/decode_bool_test.go index 99a8342..eb23259 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: "nall1", 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") From 0d763ef02f82e6bd6d0779acdcd16743b657bb62 Mon Sep 17 00:00:00 2001 From: Pouya1364 Date: Sat, 22 Aug 2020 17:23:07 +0800 Subject: [PATCH 6/6] Update decode_bool_test.go --- decode_bool_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decode_bool_test.go b/decode_bool_test.go index eb23259..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: "nall1", + 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")