Package dev.tachyonmcp.core.server.json
Class JsonUtils
java.lang.Object
dev.tachyonmcp.core.server.json.JsonUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final tools.jackson.core.json.JsonFactorystatic final tools.jackson.core.ObjectReadContext -
Method Summary
Modifier and TypeMethodDescriptionstatic tools.jackson.databind.JsonNodeparse(JsonDocument document) static tools.jackson.databind.JsonNodestatic tools.jackson.databind.JsonNodeparseJsonNode(String json) static ToolResultserializeStructured(ToolResult result, PayloadSerializer serializer) Serializes non-tree structured values in aToolResultintoJsonDocument.toJsonNodeMap(@Nullable Map<String, ?> values) toObjectMap(@Nullable Map<String, tools.jackson.databind.JsonNode> values) static tools.jackson.databind.JsonNodetoObjectNode(Map<String, ?> fields) Builds an objectJsonNodefrom an ordered field map, preserving field order and explicitnullvalues (mapped to JSONnullrather than omitted).static <T> @Nullable tools.jackson.databind.JsonNodevalueToObjectNode(@Nullable T value, PayloadSerializer serializer) Converts a given value into aJsonNoderepresenting an object, if applicable.static StringwriteString(Object value)
-
Field Details
-
FACTORY
public static final tools.jackson.core.json.JsonFactory FACTORY -
TREE_READ_CONTEXT
public static final tools.jackson.core.ObjectReadContext TREE_READ_CONTEXT
-
-
Method Details
-
parse
-
parse
-
writeString
-
toJsonNodeMap
-
toObjectMap
-
toObjectNode
Builds an objectJsonNodefrom an ordered field map, preserving field order and explicitnullvalues (mapped to JSONnullrather than omitted). NestedMapandListvalues are converted recursively; other values are serialized with the JSON-RPC serializer. Use it to emit hand-shaped wire objects for protocol versions that lack generated codecs. -
parseJsonNode
-
valueToObjectNode
public static <T> @Nullable tools.jackson.databind.JsonNode valueToObjectNode(@Nullable T value, PayloadSerializer serializer) Converts a given value into aJsonNoderepresenting an object, if applicable. The method supports the following input types: -JsonDocument, where the contained JSON string is parsed into aJsonNode. -JsonNode, if it is already an object node. -Map, where its entries are transformed into an object node. - Other non-null values: serialized via the providedPayloadSerializer.- Type Parameters:
T- the type of the value to be converted- Parameters:
value- the value to be convertedserializer- the serializer for non-tree values- Returns:
- a
JsonNodeobject node representation of the value, ornullif the value cannot be converted
-
serializeStructured
Serializes non-tree structured values in aToolResultintoJsonDocument.JsonNodeandJsonDocumentpass through. Maps carryingJsonNodevalues are serialized with Jackson regardless of the configured serializer — a non-Jackson serde cannot encode Jackson trees.
-