Skip to content

Format binary data function #11

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),
    };
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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