Skip to main content

json_to_tsv

Function json_to_tsv 

Source
pub fn json_to_tsv(json: &str) -> Result<String, Box<dyn Error>>
Expand description

Converts a JSON array of objects into a TSV string.

Same semantics as json_to_csv, but fields are separated by a tab character. The output uses \n line endings.

§Errors

Returns an error if the input is not an array of objects, contains nested values, or if writing fails.

§Examples

use sheeter_engine::json_to_tsv;

let json = r#"[{"name":"Alice","age":"30"},{"name":"Bob","age":"25"}]"#;
assert_eq!(json_to_tsv(json).unwrap(), "name\tage\nAlice\t30\nBob\t25\n");