File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -51,12 +51,16 @@ func (b *ctx) append(prefix string) *ctx {
5151
5252// ReadVal copy the underlying JSON into go interface, same as json.Unmarshal
5353func (iter * Iterator ) ReadVal (obj interface {}) {
54- typ := reflect2 .TypeOf (obj )
55- if typ .Kind () != reflect .Ptr {
56- iter .ReportError ("ReadVal" , "can only unmarshal into pointer" )
57- return
54+ cacheKey := reflect2 .RTypeOf (obj )
55+ decoder := iter .cfg .getDecoderFromCache (cacheKey )
56+ if decoder == nil {
57+ typ := reflect2 .TypeOf (obj )
58+ if typ .Kind () != reflect .Ptr {
59+ iter .ReportError ("ReadVal" , "can only unmarshal into pointer" )
60+ return
61+ }
62+ decoder = iter .cfg .DecoderOf (typ )
5863 }
59- decoder := iter .cfg .DecoderOf (typ )
6064 ptr := reflect2 .PtrOf (obj )
6165 if ptr == nil {
6266 iter .ReportError ("ReadVal" , "can not read into nil pointer" )
You can’t perform that action at this time.
0 commit comments