Class JsonRpcCodec
java.lang.Object
dev.tachyonmcp.core.transport.jsonrpc.JsonRpcCodec
Low-level JSON-RPC 2.0 codec: parse and serialize messages to/from Netty
ByteBuf.-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonRpcMessageparseRequest(io.netty.buffer.ByteBuf buf) Parses a JSON-RPC message from aByteBuf.static @Nullable ObjectreadGenericValue(tools.jackson.core.JsonParser p) Reads the current JSON token as a generic Java value.static StringreadRawJson(tools.jackson.core.JsonParser p) Reads the remainder of the current JSON value as a raw JSON string.static tools.jackson.databind.JsonNodereadTreeValue(tools.jackson.core.JsonParser p) Reads the current JSON value as aJsonNode.static @Nullable ObjectDeserializes a JSON string to a generic Java object (Map, List, String, Number, Boolean, or null).static byte[]serializeError(@Nullable RequestId id, int code, String message, @Nullable String dataJson) Serializes a JSON-RPC error response.static StringserializeNotificationAsString(String method, String paramsJson) Serializes a JSON-RPC notification to a string.static StringserializeRequestAsString(RequestId id, String method, String paramsJson) Serializes a JSON-RPC request to a string.static byte[]serializeResponse(@Nullable RequestId id, @Nullable String resultJson) Serializes a JSON-RPC response.static StringtoJsonParams(@Nullable Object params) Serializes JSON-RPC params to a JSON string: strings pass through as already-serialized JSON,nullbecomes an empty object, everything else goes throughwriteValueAsString(java.lang.Object).static voidwriteJsonValue(tools.jackson.core.JsonGenerator gen, @Nullable Object value) Writes a Java object as a JSON value via the given generator.static @Nullable StringwriteValueAsString(@Nullable Object value) Serializes a Java object to a JSON string, using registered codecs when available.
-
Method Details
-
parseRequest
Parses a JSON-RPC message from aByteBuf. -
serializeResponse
Serializes a JSON-RPC response. -
serializeError
public static byte[] serializeError(@Nullable RequestId id, int code, String message, @Nullable String dataJson) Serializes a JSON-RPC error response. -
serializeNotificationAsString
Serializes a JSON-RPC notification to a string. -
serializeRequestAsString
Serializes a JSON-RPC request to a string. -
readRawJson
Reads the remainder of the current JSON value as a raw JSON string. -
readTreeValue
public static tools.jackson.databind.JsonNode readTreeValue(tools.jackson.core.JsonParser p) throws IOException Reads the current JSON value as aJsonNode.- Throws:
IOException
-
readValue
Deserializes a JSON string to a generic Java object (Map, List, String, Number, Boolean, or null). -
readGenericValue
Reads the current JSON token as a generic Java value.- Throws:
IOException
-
toJsonParams
Serializes JSON-RPC params to a JSON string: strings pass through as already-serialized JSON,nullbecomes an empty object, everything else goes throughwriteValueAsString(java.lang.Object). -
writeValueAsString
Serializes a Java object to a JSON string, using registered codecs when available. -
writeJsonValue
Writes a Java object as a JSON value via the given generator.
-