forked from mirror/go-json
fix: use stringDecoder for decode escaped string to empty interface
This commit is contained in:
parent
10de43128b
commit
405201e4f9
|
@ -275,23 +275,15 @@ func (d *interfaceDecoder) decodeEmptyInterface(buf []byte, cursor int64, p unsa
|
||||||
*(*interface{})(p) = v
|
*(*interface{})(p) = v
|
||||||
}).decode(buf, cursor, p)
|
}).decode(buf, cursor, p)
|
||||||
case '"':
|
case '"':
|
||||||
cursor++
|
var v string
|
||||||
start := cursor
|
ptr := unsafe.Pointer(&v)
|
||||||
for {
|
dec := newStringDecoder(d.structName, d.fieldName)
|
||||||
switch buf[cursor] {
|
cursor, err := dec.decode(buf, cursor, ptr)
|
||||||
case '\\':
|
if err != nil {
|
||||||
cursor++
|
return 0, err
|
||||||
continue
|
}
|
||||||
case '"':
|
**(**interface{})(unsafe.Pointer(&p)) = v
|
||||||
literal := buf[start:cursor]
|
|
||||||
cursor++
|
|
||||||
**(**interface{})(unsafe.Pointer(&p)) = *(*string)(unsafe.Pointer(&literal))
|
|
||||||
return cursor, nil
|
return cursor, nil
|
||||||
case nul:
|
|
||||||
return 0, errUnexpectedEndOfJSON("string", cursor)
|
|
||||||
}
|
|
||||||
cursor++
|
|
||||||
}
|
|
||||||
case 't':
|
case 't':
|
||||||
if cursor+3 >= int64(len(buf)) {
|
if cursor+3 >= int64(len(buf)) {
|
||||||
return 0, errUnexpectedEndOfJSON("bool(true)", cursor)
|
return 0, errUnexpectedEndOfJSON("bool(true)", cursor)
|
||||||
|
|
Loading…
Reference in New Issue