Class JsonWriteOptions

java.lang.Object
org.apache.datafusion.JsonWriteOptions

public final class JsonWriteOptions extends Object
Configuration knobs for writing JSON, passed to DataFrame.writeJson(String, JsonWriteOptions).

Mirrors a subset of DataFusion's DataFrameWriteOptions and the writer-side JsonOptions. All setters return this for fluent chaining. Defaults: every field null or empty (meaning the DataFusion default is used).

Path semantics: when singleFileOutput(boolean) is true, the path passed to writeJson is the literal output filename. When left unset (the default) and there are no partition columns, the path is treated as a directory that DataFusion populates with one or more part-files.

The output is always newline-delimited JSON (NDJSON). DataFusion's JSON writer does not emit the bracketed array form, so there is no toggle for it here.

Compression reuses FileCompressionType -- the same codec set (UNCOMPRESSED, GZIP, BZIP2, XZ, ZSTD) the read side and the CSV writer accept.

  • Constructor Details

    • JsonWriteOptions

      public JsonWriteOptions()
  • Method Details

    • singleFileOutput

      public JsonWriteOptions singleFileOutput(boolean v)
      When true, write to a single file at the supplied path. When left unset (the default) and no partition columns are configured, the path is treated as a directory and DataFusion writes one or more part-files.
    • partitionCols

      public JsonWriteOptions partitionCols(String... cols)
      Hive-style partition columns. Each column listed here is removed from the data rows and encoded into the directory layout (one subdirectory per distinct value). Mutually exclusive with singleFileOutput(boolean) -- DataFusion rejects the combination at write time.
    • fileCompressionType

      public JsonWriteOptions fileCompressionType(FileCompressionType t)
      Output compression codec. Defaults to uncompressed.