pub fn csv_to_json(csv: &str) -> Result<String, Box<dyn Error>>Expand description
Converts a CSV string into a JSON array of objects.
CSV (Comma-Separated Values) is a simple tabular format. This function reads the first row as the header and each subsequent row as a record, producing a JSON array of objects. All values are emitted as JSON strings.
§Errors
Returns an error on malformed CSV, duplicate headers, or JSON failure.
§Examples
use sheeter_engine::csv_to_json;
let csv = "name,age\nAlice,30\nBob,25";
let json = csv_to_json(csv).unwrap();
assert_eq!(json, r#"[{"name":"Alice","age":"30"},{"name":"Bob","age":"25"}]"#);