Class VariantUtils
java.lang.Object
io.confluent.kafka.schemaregistry.type.VariantUtils
Converts between Jackson
JsonNode and Variant (metadata + value binary pair).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic VariantParses a JSON string into a Variant using the shared mapper.static VariantfromJsonNode(com.fasterxml.jackson.databind.JsonNode node) Converts a Jackson JsonNode into a Variant.static com.fasterxml.jackson.databind.JsonNodetoJsonNode(Variant variant) Converts a Variant into a Jackson JsonNode.static StringtoJsonString(Variant variant) Converts a Variant into a JSON string.
-
Constructor Details
-
VariantUtils
public VariantUtils()
-
-
Method Details
-
toJsonNode
Converts a Variant into a Jackson JsonNode.Decimals are returned as a
DecimalNode, so their serialized text depends on the caller's generator: a default generator may emit scientific notation for small-magnitude decimals.toJsonString(io.confluent.kafka.schemaregistry.type.Variant)is the canonical string form and always renders decimals in fixed-point.- Parameters:
variant- the Variant to convert- Returns:
- a JsonNode representing the variant value
-
toJsonString
Converts a Variant into a JSON string. This is the canonical cross-language form: decimals are fixed-point (never scientific) and temporal types are ISO-8601 with the seconds field always present.- Parameters:
variant- the Variant to convert- Returns:
- the JSON string representation
-
fromJson
Parses a JSON string into a Variant using the shared mapper. Bareword non-finite numbers (NaN,Infinity,-Infinity) are accepted, as are out-of-range magnitudes (1e400becomesInfinity).- Parameters:
json- the JSON string to parse- Returns:
- a Variant containing the encoded metadata and value
- Throws:
IllegalArgumentException- if the JSON cannot be parsed
-
fromJsonNode
Converts a Jackson JsonNode into a Variant.- Parameters:
node- the JSON node to convert- Returns:
- a Variant containing the encoded metadata and value
-