Class JsonSchemaElementJsonUtils
java.lang.Object
dev.langchain4j.internal.JsonSchemaElementJsonUtils
Converts between
JsonSchemaElement and JSON Schema Map representation
with round-trip fidelity.
Unlike JsonSchemaElementUtils.toMap(JsonSchemaElement), which is optimized for
LLM provider APIs and intentionally omits fields like additionalProperties in
non-strict mode, this class preserves all fields needed for lossless serialization and
deserialization.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonSchemaElementConverts a standard JSON SchemaMaprepresentation back to aJsonSchemaElement.toMap(JsonSchemaElement element) Converts aJsonSchemaElementto a standard JSON SchemaMaprepresentation.
-
Method Details
-
toMap
Converts aJsonSchemaElementto a standard JSON SchemaMaprepresentation. -
fromMap
Converts a standard JSON SchemaMaprepresentation back to aJsonSchemaElement.Only the subset of JSON Schema expressible by
JsonSchemaElementsubtypes is supported. When a map contains additional JSON Schema keywords (e.g.,format,pattern,minimum, schema-valuedadditionalProperties) that cannot be represented by the corresponding typed schema, the entire node falls back toJsonRawSchemato preserve round-trip fidelity. The fallback granularity is per-node: a parentJsonObjectSchemacan still be typed even if a child property falls back to raw.- Throws:
IllegalArgumentException- if the map contains structurally invalid values (e.g.,$refis not a string,anyOfis not a list,propertiescontains a non-object value)
-