Skip to content

Format binary data function #11

@eirnym

Description

@eirnym

Binary data formatter is alreay there, I'd like it to be exposed as a public function.

Sample function is below. There's no need to copy original data as well as to have input to be mutable

fn format_json_binary(data: &Vec<u8>) -> Result<Vec<u8>, io::Error> {
    let mut formatter = jsonxf::Formatter::pretty_printer();
    let mut output: Vec<u8> = vec![];
    let mut input = BufReader::new(data.as_slice());
    return match formatter.format_stream(&mut input, &mut output) {
        Ok(_) => Ok(output),
        Err(f) => Err(f),
    };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions