diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-07 12:45:46 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-07 14:05:37 -0700 |
commit | 643cbc4d6e37d07619bec05039da1abb411d28d4 (patch) | |
tree | 68f771d5103d0243ed49b21ff896f01e49a81a72 /decode.go | |
parent | 2b9473f5e8816eeea76b2fdada184532be00d3a2 (diff) |
Move struct-handling to internal/jsonstruct
Diffstat (limited to 'decode.go')
-rw-r--r-- | decode.go | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -26,6 +26,7 @@ import ( "git.lukeshu.com/go/lowmemjson/internal/base64dec" "git.lukeshu.com/go/lowmemjson/internal/fastio" "git.lukeshu.com/go/lowmemjson/internal/jsonparse" + "git.lukeshu.com/go/lowmemjson/internal/jsonstruct" ) // Decodable is the interface implemented by types that can decode a @@ -532,7 +533,7 @@ func (dec *Decoder) decode(val reflect.Value, nullOK bool) { dec.decodeNull() return } - index := indexStruct(typ) + index := jsonstruct.IndexStruct(typ) var nameBuf strings.Builder dec.decodeObject(typ, func() { dec.posStackPush() @@ -545,10 +546,10 @@ func (dec *Decoder) decode(val reflect.Value, nullOK bool) { name := nameBuf.String() dec.structStackPush(typ, name) defer dec.structStackPop() - idx, ok := index.byName[name] + idx, ok := index.ByName[name] if !ok { - for oidx := range index.byPos { - if strings.EqualFold(name, index.byPos[oidx].Name) { + for oidx := range index.ByPos { + if strings.EqualFold(name, index.ByPos[oidx].Name) { idx = oidx ok = true break @@ -562,7 +563,7 @@ func (dec *Decoder) decode(val reflect.Value, nullOK bool) { dec.scan(fastio.Discard) return } - field := index.byPos[idx] + field := index.ByPos[idx] fVal := val for _, idx := range field.Path { if fVal.Kind() == reflect.Pointer { |