ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.85k stars 295 forks source link

bug: json decoder is broken #307

Closed primalmotion closed 5 years ago

primalmotion commented 5 years ago

Since commit 6fd7dc6ca2022649ecea946d225fed79aca8db45 the following code snippet is broken:

package main

import (
    "bytes"

    "github.com/ugorji/go/codec"
)

func main() {

    d := bytes.NewBuffer([]byte(`[{"slice": null}]`))
    dec := codec.NewDecoder(d, &codec.JsonHandle{})

    o := []struct {
        Slice []string `json:"slice"`
    }{}

    if err := dec.Decode(&o); err != nil {
        panic(err)
    }
}

basically prints panic: json decode error [pos 2]: reflect: slice index out of range

Using the previous commit 7865e43e776b01f708871ba4d37a9ed1d3353bfd makes that snippet work

ugorji commented 5 years ago

Great catch. My oversight.

Fix coming in soon.

primalmotion commented 5 years ago

awesome. will you make a new 1.1.5-pre? I think we are going through the same pain switching to go modules (which is an absolute aberration to me) and I have to deal with exclude and stuff that doesn't really work at all in practice.

ugorji commented 5 years ago

I'm definitely releasing a 1.2 this weekend.

I'm done with all my changes within the constraints of the current architecture.

ugorji commented 5 years ago

I'm definitely releasing a 1.2 this weekend.

I'm done with all my changes within the constraints of the current architecture.

Or rather 1.1.6 (sorry - the 1.2 has the re-architecture under consideration).

ugorji commented 5 years ago

I just release 1.1.6 - see https://github.com/ugorji/go/releases/tag/v1.1.6

ugorji commented 5 years ago

I just released a go-codec production release - version 1.1.7 (finally) with the fixes to ensure the import paths github.com/ugorji/go and github.com/ugorji/go/codec both work seamlessly.

Please let me know if seeing any issues. If all is well over the next few days, I will close this github issue.

See

https://github.com/ugorji/go/releases/latest https://github.com/ugorji/go/releases/tag/v1.1.7