MCPcopy Create free account
hub / github.com/IBM/newrelic-cli / GuessJSONStream

Function GuessJSONStream

utils/decoder.go:325–329  ·  view source on GitHub ↗

GuessJSONStream scans the provided reader up to size, looking for an open brace indicating this is JSON. It will return the bufio.Reader it creates for the consumer.

(r io.Reader, size int)

Source from the content-addressed store, hash-verified

323// for an open brace indicating this is JSON. It will return the
324// bufio.Reader it creates for the consumer.
325func GuessJSONStream(r io.Reader, size int) (io.Reader, []byte, bool) {
326 buffer := bufio.NewReaderSize(r, size)
327 b, _ := buffer.Peek(size)
328 return buffer, b, hasJSONPrefix(b)
329}
330
331var jsonPrefix = []byte("{")
332

Callers 1

DecodeMethod · 0.85

Calls 1

hasJSONPrefixFunction · 0.85

Tested by

no test coverage detected