Codec
Category: Jsonrpc
Source: codec.dart
Encodes JSON-RPC messages to/from the wire format.
Pure functions; no I/O. See transport/stdio.dart for the stdio framing that drives this codec.
Functions
Map<String, Object?> encodeJsonRpc(JsonRpcMessage message)
Serializes a [JsonRpcMessage] to its on-the-wire JSON object form.
String encodeJsonRpcString(JsonRpcMessage message)
Encodes a [JsonRpcMessage] as a single JSON string.
JsonRpcMessage decodeJsonRpc(Map<String, Object?> payload)
Decodes a parsed JSON object into the right [JsonRpcMessage] subtype.
Returns a [JsonRpcError] with [JsonRpcErrorCode.invalidRequest] if the payload is structurally wrong; throws [FormatException] for shapes the server should treat as parse errors.
JsonRpcMessage decodeJsonRpcString(String line)
Decodes a single JSON string into a [JsonRpcMessage]. Returns a JsonRpcError(parseError) if the line is not valid JSON.