ohler55 / ojg

Optimized JSON for Go
MIT License
857 stars 49 forks source link

oj.Unmarshal fails on arrays #151

Closed right-mouse closed 10 months ago

right-mouse commented 11 months ago

Simple example:

var f [4]int
err := oj.Unmarshal(`[1,2,3,4]`, &f)

The following error is returned: reflect.MakeSlice of non-slice type

Playground: https://go.dev/play/p/Qasyi87zIFb

ohler55 commented 10 months ago

Please try the "arrays" branch. The example will not work as Unmarshal converts all numbers to float64 what can not be assigned to ints. Parse should work though. I still have some more edge case to test and need to compare to the core json library to see if it handles the example.

ohler55 commented 10 months ago

ok, updated to handle the test case. Should be ready.

ohler55 commented 10 months ago

Released v1.21.0

right-mouse commented 10 months ago

Works as expected. Thanks for the fix.