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 uses Base16 Encoding
As per RFC7159 JSON cannot encode arbitrary binary data. This crate works around that
limitation by encoding/decoding binary data as a hexadecimal string (i.e.
Base16 encoding).
Note that Base16 only has 50% space efficiency (i.e., the encoded data is twice as large
as the original). If that is an issue, we recommend to convert binary data to/from a different
encoding format such as Base64 instead. See the following example for details.
Base64 Encoding Example
Base64 is a common binary-to-text encoding scheme with a space efficiency of 75%. The
following example shows how to use the [arrow_cast] crate to encode binary data to Base64
before converting it to JSON and how to decode it back.
# use Cursor;
# use Arc;
# use ;
# use AsArray;
use ;
# use ;
#
// The data we want to write
let input = from;
// Base64 encode it to a string
let encoded: StringArray = b64_encode;
// Write the StringArray to JSON
let batch = try_from_iter.unwrap;
let mut buf = Vecwith_capacity;
let mut writer = new;
writer.write.unwrap;
writer.finish.unwrap;
// Read the JSON data
let cursor = new;
let mut reader = new.build.unwrap;
let batch = reader.next.unwrap.unwrap;
// Reverse the base64 encoding
let col: BinaryArray = batch.column..clone.into;
let output = b64_decode.unwrap;
assert_eq!;