MCPcopy
hub / github.com/tinylib/msgp / UnmarshalAsJSON

Function UnmarshalAsJSON

msgp/json_bytes.go:40–60  ·  view source on GitHub ↗

UnmarshalAsJSON takes raw messagepack and writes it as JSON to 'w'. If an error is returned, the bytes not translated will also be returned. If no errors are encountered, the length of the returned slice will be zero.

(w io.Writer, msg []byte)

Source from the content-addressed store, hash-verified

38// no errors are encountered, the length of the returned
39// slice will be zero.
40func UnmarshalAsJSON(w io.Writer, msg []byte) ([]byte, error) {
41 var (
42 scratch []byte
43 cast bool
44 dst jsWriter
45 err error
46 )
47 if jsw, ok := w.(jsWriter); ok {
48 dst = jsw
49 cast = true
50 } else {
51 dst = bufio.NewWriterSize(w, 512)
52 }
53 for len(msg) > 0 && err == nil {
54 msg, scratch, err = writeNext(dst, msg, scratch, 0)
55 }
56 if !cast && err == nil {
57 err = dst.(*bufio.Writer).Flush()
58 }
59 return msg, err
60}
61
62func writeNext(w jsWriter, msg []byte, scratch []byte, depth int) ([]byte, []byte, error) {
63 if len(msg) < 1 {

Callers 9

encDecCustomTagFunction · 0.92
TestJSONNumberReplaceFunction · 0.92
TestJSONNumberFunction · 0.92
TestReadIntfRecursionFunction · 0.85
FuzzReadBytesFunction · 0.85
TestUnmarshalJSONFunction · 0.85
BenchmarkUnmarshalAsJSONFunction · 0.85
MarshalJSONMethod · 0.85

Calls 2

writeNextFunction · 0.85
FlushMethod · 0.80

Tested by 8

encDecCustomTagFunction · 0.74
TestJSONNumberReplaceFunction · 0.74
TestJSONNumberFunction · 0.74
TestReadIntfRecursionFunction · 0.68
FuzzReadBytesFunction · 0.68
TestUnmarshalJSONFunction · 0.68
BenchmarkUnmarshalAsJSONFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…