Jefffrey commented on code in PR #5065:
URL: https://github.com/apache/arrow-rs/pull/5065#discussion_r1399064293
##########
arrow-json/src/writer.rs:
##########
@@ -494,21 +575,36 @@ impl JsonFormat for JsonArray {
}
}
-/// A JSON writer which serializes [`RecordBatch`]es to newline delimited JSON
objects
-pub type LineDelimitedWriter<W> = Writer<W, LineDelimited>;
+/// A JSON writer which serializes [`RecordBatch`]es to newline delimited JSON
objects.
+///
+/// Will skip writing keys with null values.
+pub type LineDelimitedWriter<W> = Writer<W, LineDelimited, SkipNulls>;
-/// A JSON writer which serializes [`RecordBatch`]es to JSON arrays
-pub type ArrayWriter<W> = Writer<W, JsonArray>;
+/// Similar to [`LineDelimitedWriter`] but will keep keys with null values.
+pub type LineDelimitedWriterWithNulls<W> = Writer<W, LineDelimited, KeepNulls>;
+
+/// A JSON writer which serializes [`RecordBatch`]es to JSON arrays.
+///
+/// Will skip writing keys with null values.
+pub type ArrayWriter<W> = Writer<W, JsonArray, SkipNulls>;
+
+/// Similar to [`ArrayWriter`] but will keep keys with null values.
+pub type ArrayWriterWithNulls<W> = Writer<W, JsonArray, KeepNulls>;
/// A JSON writer which serializes [`RecordBatch`]es to a stream of
-/// `u8` encoded JSON objects. See the module level documentation for
-/// detailed usage and examples. The specific format of the stream is
-/// controlled by the [`JsonFormat`] type parameter.
+/// `u8` encoded JSON objects.
+///
+/// See the module level documentation for detailed usage and examples.
+/// The specific format of the stream is controlled by the [`JsonFormat`]
+/// type parameter. The [`NullHandler`] type parameter controls whether
+/// nulls should be written explicitly for keys or skipped. Default is
+/// [`SkipNulls`] for backward compatibility.
#[derive(Debug)]
-pub struct Writer<W, F>
+pub struct Writer<W, F, N = SkipNulls>
where
W: Write,
F: JsonFormat,
+ N: NullHandler,
Review Comment:
Changed to be configured via a WriterBuilder now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]