Package io.delta.kernel.internal.util
Class JsonUtils
Object
io.delta.kernel.internal.util.JsonUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionstatic com.fasterxml.jackson.core.JsonFactoryfactory()static Stringgenerate(JsonUtils.ToJson toJson) Utility class for writing JSON with a JacksonJsonGenerator.static com.fasterxml.jackson.databind.ObjectMappermapper()parseJSONKeyValueMap(String jsonString) Parses the given JSON string into a map of key-value pairs.static LiteralparseJsonValueToLiteral(com.fasterxml.jackson.databind.JsonNode valueNode, DataType dataType) Helper method to convert JSON node value to Literal based on the expected data type from schema.
-
Method Details
-
factory
public static com.fasterxml.jackson.core.JsonFactory factory() -
mapper
public static com.fasterxml.jackson.databind.ObjectMapper mapper() -
generate
Utility class for writing JSON with a JacksonJsonGenerator.- Parameters:
toJson- function that produces JSON using aJsonGenerator- Returns:
- a JSON string produced from the generator
-
parseJSONKeyValueMap
Parses the given JSON string into a map of key-value pairs.The JSON string should be in the format:
where both keys and values are strings.{"key1": "value1", "key2": "value2", ...}- Parameters:
jsonString- The JSON string to parse- Returns:
- A map containing the key-value pairs extracted from the JSON string
-
parseJsonValueToLiteral
public static Literal parseJsonValueToLiteral(com.fasterxml.jackson.databind.JsonNode valueNode, DataType dataType) Helper method to convert JSON node value to Literal based on the expected data type from schema. Uses the schema type information to eliminate ambiguity when parsing JSON values.- Parameters:
valueNode- The JSON node containing the valuedataType- The expected data type from the schema- Returns:
- The corresponding Literal, or null if the value is null
- Throws:
KernelException- if the JSON value cannot be parsed as the expected type
-