in json/parse.go [463:513]
func (p *Parser) doString(b []byte) ([]byte, bool, bool, []byte, error) {
stop := -1
done := false
delta := 1
buf := b
atStart := len(p.literalBuffer) == 0
if atStart {
delta = 2
buf = b[1:]
}
inEscape := p.inEscape
for i, c := range buf {
if inEscape {
inEscape = false
continue
}
if c == '"' {
done = true
stop = i + delta
break
} else if c == '\\' {
inEscape = true
}
}
p.inEscape = inEscape
if !done {
p.literalBuffer = append(p.literalBuffer, b...)
return nil, false, false, nil, nil
}
rest := b[stop:]
b = b[:stop]
if len(p.literalBuffer) > 0 {
b = append(p.literalBuffer, b...)
p.literalBuffer = b[:0] // reset buffer
}
var err error
var allocated bool
b = b[1 : len(b)-1]
b, allocated, err = p.unquote(b)
if err != nil {
return nil, false, false, nil, err
}
return b, allocated, done, rest, nil
}