25 major breaking releases

52.1.0 Jul 6, 2024
51.0.0 Mar 18, 2024
50.0.0 Jan 12, 2024
49.0.0 Nov 13, 2023
27.0.0 Nov 14, 2022

#227 in Parser implementations

Download history 81916/week @ 2024-04-05 105237/week @ 2024-04-12 135366/week @ 2024-04-19 128497/week @ 2024-04-26 125152/week @ 2024-05-03 141696/week @ 2024-05-10 137617/week @ 2024-05-17 135965/week @ 2024-05-24 205951/week @ 2024-05-31 234793/week @ 2024-06-07 204875/week @ 2024-06-14 255381/week @ 2024-06-21 248685/week @ 2024-06-28 234928/week @ 2024-07-05 234995/week @ 2024-07-12 189195/week @ 2024-07-19

962,167 downloads per month
Used in 31 crates (9 directly)

Apache-2.0

2.5MB
55K SLoC

Transfer data between the Arrow memory format and JSON line-delimited records.

See the module level documentation for the reader and writer for usage examples.

Binary Data

As per RFC7159 JSON cannot encode arbitrary binary data. A common approach to workaround this is to use a binary-to-text encoding scheme, such as base64, to encode the input data and then decode it on output.

#
// The data we want to write
let input = BinaryArray::from(vec![b"\xDE\x00\xFF".as_ref()]);

// Base64 encode it to a string
let encoded: StringArray = b64_encode(&BASE64_STANDARD, &input);

// Write the StringArray to JSON
let batch = RecordBatch::try_from_iter([("col", Arc::new(encoded) as _)]).unwrap();
let mut buf = Vec::with_capacity(1024);
let mut writer = LineDelimitedWriter::new(&mut buf);
writer.write(&batch).unwrap();
writer.finish().unwrap();

// Read the JSON data
let cursor = Cursor::new(buf);
let mut reader = ReaderBuilder::new(batch.schema()).build(cursor).unwrap();
let batch = reader.next().unwrap().unwrap();

// Reverse the base64 encoding
let col: BinaryArray = batch.column(0).as_string::<i32>().clone().into();
let output = b64_decode(&BASE64_STANDARD, &col).unwrap();

assert_eq!(input, output);

Dependencies

~6–12MB
~135K SLoC