mirror of
https://github.com/json-iterator/go.git
synced 2025-01-08 13:06:29 +02:00
fix unsafe reference
This commit is contained in:
parent
f154c8a934
commit
c352559e52
@ -10,6 +10,7 @@ func Test_read_map(t *testing.T) {
|
||||
iter := ParseString(`{"hello": "world"}`)
|
||||
m := map[string]string{"1": "2"}
|
||||
iter.Read(&m)
|
||||
copy(iter.buf, []byte{0,0,0,0,0,0})
|
||||
if !reflect.DeepEqual(map[string]string{"1": "2", "hello": "world"}, m) {
|
||||
fmt.Println(iter.Error)
|
||||
t.Fatal(m)
|
||||
|
@ -327,7 +327,7 @@ func (decoder *mapDecoder) decode(ptr unsafe.Pointer, iter *Iterator) {
|
||||
for field := iter.ReadObject(); field != ""; field = iter.ReadObject() {
|
||||
elem := reflect.New(decoder.elemType)
|
||||
decoder.elemDecoder.decode(unsafe.Pointer(elem.Pointer()), iter)
|
||||
realVal.SetMapIndex(reflect.ValueOf(field), elem.Elem())
|
||||
realVal.SetMapIndex(reflect.ValueOf(string([]byte(field))), elem.Elem())
|
||||
}
|
||||
}
|
||||
|
||||
@ -514,7 +514,7 @@ func (iter *Iterator) ReadAny() (ret *Any) {
|
||||
if iter.Error != nil {
|
||||
return
|
||||
}
|
||||
val[field] = element.val
|
||||
val[string([]byte(field))] = element.val
|
||||
}
|
||||
return MakeAny(val)
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user