forked from mirror/go-json
Merge pull request #102 from goccy/feature/fix-decoding-escaped-char
Fix decoding of escape char at UnmarshalJSON
This commit is contained in:
commit
c655881253
|
@ -218,6 +218,7 @@ func (d *interfaceDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (i
|
|||
switch buf[cursor] {
|
||||
case '\\':
|
||||
cursor++
|
||||
continue
|
||||
case '"':
|
||||
literal := buf[start:cursor]
|
||||
cursor++
|
||||
|
|
|
@ -226,6 +226,14 @@ func Test_Decoder(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestIssue98(t *testing.T) {
|
||||
data := "[\"\\"
|
||||
var v interface{}
|
||||
if err := json.Unmarshal([]byte(data), &v); err == nil {
|
||||
t.Fatal("expected error")
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Decoder_UseNumber(t *testing.T) {
|
||||
dec := json.NewDecoder(strings.NewReader(`{"a": 3.14}`))
|
||||
dec.UseNumber()
|
||||
|
|
Loading…
Reference in New Issue