File tree 1 file changed +9
-5
lines changed
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 {
51
51
52
52
// ReadVal copy the underlying JSON into go interface, same as json.Unmarshal
53
53
func (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 )
58
63
}
59
- decoder := iter .cfg .DecoderOf (typ )
60
64
ptr := reflect2 .PtrOf (obj )
61
65
if ptr == nil {
62
66
iter .ReportError ("ReadVal" , "can not read into nil pointer" )
You can’t perform that action at this time.
0 commit comments