Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not unmarshal into []uint8 #360

Closed
handsomejack-kiwi opened this issue Apr 6, 2022 · 0 comments · Fixed by #361
Closed

can not unmarshal into []uint8 #360

handsomejack-kiwi opened this issue Apr 6, 2022 · 0 comments · Fixed by #361

Comments

@handsomejack-kiwi
Copy link

Hi goccy,

there's a problem when unmarshalling into []uint8, see below example:

package main

import (
	"fmt"

	"github.com/goccy/go-json"
)


func main() {
	var uints []uint8
	err := json.Unmarshal([]byte(`[0, 1, 2]`), &uints)
	if err != nil {
		panic(err)
	}
	fmt.Println(uints)
}

which produces

panic: json: cannot unmarshal into Go value of type uint8

The above example does, however, work as expected with encoding/json.

PS: Quickly checking, I couldn't find another type that would suffer from this, besides []uint8.

Can you please take a look?

Cheers

orisano added a commit to orisano/go-json that referenced this issue Apr 7, 2022
goccy added a commit that referenced this issue Apr 12, 2022
fix: add a fallback uint8 sliceDecoder to bytesDecoder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant