Skip to main content

Crate format_ende_json

Crate format_ende_json 

Source
Expand description

JSON format implementation for the format-ende crate

§Example

use format_ende::FormatEncoder;
use format_ende::FormatDecoder;
use format_ende_json::JsonFormat;

use std::io::Cursor;

let mut format = JsonFormat::new();
format.pretty = true; // Enable pretty printing

let mut buf: Vec<u8> = Vec::new();
let value = vec![
    String::from("foo"),
    String::from("bar"),
    String::from("baz")
];

// Encode the value to JSON
format.encode(&mut buf, &value).unwrap();

// Decode the value back from JSON
let decoded: Vec<String> = format.decode(Cursor::new(buf)).unwrap();

assert_eq!(decoded, value);

Structs§

JsonFormat
Struct representing the format-ende implementation for the JSON format