MCPcopy Create free account
hub / github.com/CPChain/chain / NewJSONCodec

Function NewJSONCodec

api/rpc/json.go:111–122  ·  view source on GitHub ↗

NewJSONCodec creates a new RPC server codec with support for JSON-RPC 2.0.

(rwc io.ReadWriteCloser)

Source from the content-addressed store, hash-verified

109
110// NewJSONCodec creates a new RPC server codec with support for JSON-RPC 2.0.
111func NewJSONCodec(rwc io.ReadWriteCloser) ServerCodec {
112 enc := json.NewEncoder(rwc)
113 dec := json.NewDecoder(rwc)
114 dec.UseNumber()
115
116 return &jsonCodec{
117 closed: make(chan interface{}),
118 encode: enc.Encode,
119 decode: dec.Decode,
120 rw: rwc,
121 }
122}
123
124// isBatch returns true when the first non-whitespace characters is '['
125func isBatch(msg json.RawMessage) bool {

Callers 7

DialInProcFunction · 0.85
ServeHTTPMethod · 0.85
TestNotificationsFunction · 0.85
ServeListenerMethod · 0.85
TestJSONRequestParsingFunction · 0.85

Calls

no outgoing calls

Tested by 4

TestNotificationsFunction · 0.68
TestJSONRequestParsingFunction · 0.68