MCPcopy
hub / github.com/pquerna/ffjson / SliceString

Method SliceString

fflib/v1/reader.go:223–252  ·  view source on GitHub ↗
(out DecodingBuffer)

Source from the content-addressed store, hash-verified

221}
222
223func (r *ffReader) SliceString(out DecodingBuffer) error {
224 var c byte
225 // TODO(pquerna): string_with_escapes? de-escape here?
226 j := r.i
227
228 for {
229 if j >= r.l {
230 return io.EOF
231 }
232
233 j, c = scanString(r.s, j)
234
235 if c == '"' {
236 if j != r.i {
237 out.Write(r.s[r.i : j-1])
238 r.i = j
239 }
240 return nil
241 } else if c == '\\' {
242 var err error
243 j, err = r.handleEscaped(c, j, out)
244 if err != nil {
245 return err
246 }
247 } else if byteLookupTable[c]&cIJC != 0 {
248 return fmt.Errorf("lex_string_invalid_json_char: %v", c)
249 }
250 continue
251 }
252}
253
254// TODO(pquerna): consider combining wibth the normal byte mask.
255var whitespaceLookupTable [256]bool = [256]bool{

Callers 5

tsliceStringFunction · 0.80
TestBadUnicodeFunction · 0.80
TestNonUnicodeEscapeFunction · 0.80
TestInvalidEscapeFunction · 0.80
lexStringMethod · 0.80

Calls 3

handleEscapedMethod · 0.95
scanStringFunction · 0.85
WriteMethod · 0.45

Tested by 4

tsliceStringFunction · 0.64
TestBadUnicodeFunction · 0.64
TestNonUnicodeEscapeFunction · 0.64
TestInvalidEscapeFunction · 0.64