1
0
mirror of https://github.com/json-iterator/go.git synced 2025-07-06 23:37:39 +02:00

#129 fix read map with reader, should use ReadMapCB instead of ReadObjectCB

This commit is contained in:
Tao Wen
2017-07-12 16:40:05 +08:00
parent 845d8438db
commit bd4364ab7c
3 changed files with 17 additions and 4 deletions

View File

@ -89,7 +89,7 @@ func (any *objectLazyAny) Get(path ...interface{}) Any {
mappedAll := map[string]Any{}
iter := any.cfg.BorrowIterator(any.buf)
defer any.cfg.ReturnIterator(iter)
iter.ReadObjectCB(func(iter *Iterator, field string) bool {
iter.ReadMapCB(func(iter *Iterator, field string) bool {
mapped := locatePath(iter, path[1:])
if mapped.ValueType() != Invalid {
mappedAll[field] = mapped
@ -108,7 +108,7 @@ func (any *objectLazyAny) Keys() []string {
keys := []string{}
iter := any.cfg.BorrowIterator(any.buf)
defer any.cfg.ReturnIterator(iter)
iter.ReadObjectCB(func(iter *Iterator, field string) bool {
iter.ReadMapCB(func(iter *Iterator, field string) bool {
iter.Skip()
keys = append(keys, field)
return true