mirror of https://github.com/goccy/go-json.git
Fix decoder
This commit is contained in:
parent
cbda08a525
commit
5e281e340f
|
@ -39,6 +39,7 @@ func unmarshal(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error {
|
||||||
}
|
}
|
||||||
ctx := decoder.TakeRuntimeContext()
|
ctx := decoder.TakeRuntimeContext()
|
||||||
ctx.Buf = src
|
ctx.Buf = src
|
||||||
|
ctx.Option.FirstWin = false
|
||||||
for _, optFunc := range optFuncs {
|
for _, optFunc := range optFuncs {
|
||||||
optFunc(ctx.Option)
|
optFunc(ctx.Option)
|
||||||
}
|
}
|
||||||
|
@ -67,6 +68,7 @@ func unmarshalNoEscape(data []byte, v interface{}, optFuncs ...DecodeOptionFunc)
|
||||||
|
|
||||||
ctx := decoder.TakeRuntimeContext()
|
ctx := decoder.TakeRuntimeContext()
|
||||||
ctx.Buf = src
|
ctx.Buf = src
|
||||||
|
ctx.Option.FirstWin = false
|
||||||
for _, optFunc := range optFuncs {
|
for _, optFunc := range optFuncs {
|
||||||
optFunc(ctx.Option)
|
optFunc(ctx.Option)
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,11 @@ func (d *wrappedStringDecoder) Decode(ctx *RuntimeContext, cursor, depth int64,
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
bytes = append(bytes, nul)
|
bytes = append(bytes, nul)
|
||||||
|
oldBuf := ctx.Buf
|
||||||
|
ctx.Buf = bytes
|
||||||
if _, err := d.dec.Decode(ctx, 0, depth, p); err != nil {
|
if _, err := d.dec.Decode(ctx, 0, depth, p); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
ctx.Buf = oldBuf
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue