Skip to main content

encode_jsonl

Function encode_jsonl 

Source
pub fn encode_jsonl(
    rows: &[LabeledExample],
) -> Result<Vec<u8>, ContrastiveDataError>
Expand description

Canonically encode rows as JSONL: serde_json::to_writer per row, then b'\n'.

Written straight into one buffer rather than joining per-row Strings, so there is no intermediate allocation whose formatting could drift from the parser’s expectations.

§Errors

ContrastiveDataError::Serialization if a row cannot be serialized.