Class JsonUtils

Object
io.delta.kernel.internal.util.JsonUtils

public class JsonUtils extends Object
  • Method Details

    • factory

      public static com.fasterxml.jackson.core.JsonFactory factory()
    • mapper

      public static com.fasterxml.jackson.databind.ObjectMapper mapper()
    • generate

      public static String generate(JsonUtils.ToJson toJson)
      Utility class for writing JSON with a Jackson JsonGenerator.
      Parameters:
      toJson - function that produces JSON using a JsonGenerator
      Returns:
      a JSON string produced from the generator
    • parseJSONKeyValueMap

      public static Map<String,String> parseJSONKeyValueMap(String jsonString)
      Parses the given JSON string into a map of key-value pairs.

      The JSON string should be in the format:

      {"key1": "value1", "key2": "value2", ...}
      where both keys and values are strings.
      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 value
      dataType - 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