Enum polars::prelude::JsonFormat
source · pub enum JsonFormat {
Json,
JsonLines,
}
polars-io
only.Expand description
The format to use to write the DataFrame to JSON: Json
(a JSON array) or JsonLines
(each row output on a
separate line). In either case, each row is serialized as a JSON object whose keys are the column names and whose
values are the row’s corresponding values.
Variants§
Json
A single JSON array containing each DataFrame row as an object. The length of the array is the number of rows in the DataFrame.
Use this to create valid JSON that can be deserialized back into an array in one fell swoop.
JsonLines
Each DataFrame row is serialized as a JSON object on a separate line. The number of lines in the output is the number of rows in the DataFrame.
The JSON Lines format makes it easy to read records in a streaming fashion, one (line) at a time. But the output in its entirety is not valid JSON; only the individual lines are.
It is recommended to use the file extension .jsonl
when saving as JSON Lines.