Created
February 8, 2015 19:32
-
-
Save darthberen/963313f71b97b029c03f to your computer and use it in GitHub Desktop.
excerpt of decode.go code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lines 559-583 in decode.go in encoding/json package | |
var f *field | |
fields := cachedTypeFields(v.Type()) | |
for i := range fields { | |
ff := &fields[i] | |
if bytes.Equal(ff.nameBytes, key) { | |
f = ff | |
break | |
} | |
if f == nil && ff.equalFold(ff.nameBytes, key) { | |
f = ff | |
} | |
} | |
if f != nil { | |
subv = v | |
destring = f.quoted | |
for _, i := range f.index { | |
if subv.Kind() == reflect.Ptr { | |
if subv.IsNil() { | |
subv.Set(reflect.New(subv.Type().Elem())) | |
} | |
subv = subv.Elem() | |
} | |
subv = subv.Field(i) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment