Class JsonUtils

Object
io.delta.kernel.defaults.internal.json.JsonUtils

public class JsonUtils extends Object
Utilities method to serialize and deserialize Row objects with a limited set of data type values.

Following are the supported data types: boolean, byte, short, int, long, float, double, string, StructType (containing any of the supported subtypes), ArrayType, MapType (only a map with string keys is supported).

At a high-level, the JSON serialization is similar to that of Jackson's ObjectMapper.

  • Method Details

    • rowToJson

      public static String rowToJson(io.delta.kernel.data.Row row)
      Converts a Row to a single line JSON string. This is currently used just in tests. Wll be used as part of the refactoring planned in #2929
      Parameters:
      row - the row to convert
      Returns:
      JSON string
    • rowFromJson

      public static io.delta.kernel.data.Row rowFromJson(String json, io.delta.kernel.types.StructType schema)
      Converts a JSON string to a Row.
      Parameters:
      json - JSON string
      schema - to read the JSON according the schema
      Returns:
      Row instance with given schema.