Skip to main content

parse

Function parse 

Source
pub fn parse(src: &str) -> Result<Value, CsvError>
Expand description

Parse a CSV source string with the shared default parser.

The engine is built once, on first use, and reused after that. Reuse is safe: Tabnas::parse takes &self and builds a fresh parse context per call, and Tabnas is Send + Sync, so concurrent callers share one installed grammar instead of each rebuilding it, which is what dominates a small parse.

Use make or make_with instead when the parser needs configuring: that returns a fresh instance and leaves this one alone.

let value = tabnas_csv::parse("a,b\n1,2\n3,4")?;
assert_eq!(value.to_json().to_string(), r#"[{"a":"1","b":"2"},{"a":"3","b":"4"}]"#);