You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package issue_test
import (
"testing"
"encoding/json"
`github.com/davecgh/go-spew/spew`
`github.com/stretchr/testify/require`
"github.com/bytedance/sonic"
)
var mapdata = `{
"ptrslice": [{"id": "1"}, {"id": "2"}, {"id": "3"}, {"id": "4"}]
}`;
type FooId struct {
Id int `json:"id"`
}
func TestUnmarshalErrorInMapSlice(t *testing.T) {
var a, b map[string][]FooId
se := json.Unmarshal([]byte(mapdata), &a)
je := sonic.Unmarshal([]byte(mapdata), &b)
spew.Dump(se, a) // len(a) = 4
spew.Dump(je, b) // len(b) = 1
require.Equal(t, a, b);
}
var slicedata = `[{"id": "1"}, {"id": "2"}, {"id": "3"}, {"id": "4"}]`;
func TestUnmarshalErrorInSlice(t *testing.T) {
var a, b []*FooId
se := json.Unmarshal([]byte(slicedata), &a)
je := sonic.Unmarshal([]byte(slicedata), &b)
spew.Dump(se, a)
spew.Dump(je, b)
require.Equal(t, a, b);
}
The text was updated successfully, but these errors were encountered:
sonic 目前在map 场景下面,解析错误后,解析后的值未与标准库对齐。
code:
The text was updated successfully, but these errors were encountered: