Repository navigation
Getting Started
Marcus Ackre Medina edited this page Sep 13, 2026
·
3 revisions
dotnet add package MarcusMedina.Fluent.DataRequires .NET 10+
using MarcusMedina.Fluent.Data.Extensions;// Escape a value for use inside a CSV line
"hello, world".ToCsvField(); // "\"hello, world\""
"normal".ToCsvField(); // "normal"
// Split a CSV line respecting quoted fields
"a,b,\"c,d\",e".SplitCsvLine(); // ["a", "b", "c,d", "e"]
// Serialize rows to a CSV document
var rows = new List<IEnumerable<object?>> { new object[] { "Anna", 30 }, new object[] { "Bob", 25 } };
rows.ToCsvDocument(); // "Anna,30\r\nBob,25"
// Parse a CSV document back into rows
"Anna,30\r\nBob,25".FromCsvDocument(); // IEnumerable<string[]>// Escape string for embedding in JSON
"say \"hello\"".ToJsonString(); // "say \\\"hello\\\""
// Validate
"{}".IsValidJson(); // true
"not json".IsValidJson(); // false
// Serialize/deserialize objects
new Person("Anna", 30).ToJson(); // "{\"name\":\"Anna\",\"age\":30}"
json.FromJson<Person>(); // Person { Name = "Anna", Age = 30 }"<b>bold</b>".ToXmlContent(); // "<b>bold</b>"
"<tag>".FromXmlContent(); // "<tag>"Every conversion is an extension method on the type you already have — a string, an object, or a collection. There's no Parser class to instantiate and no config object to build first: "a,b".SplitCsvLine() or myObject.ToJson() reads left-to-right the way the data flows. The three formats (CSV, JSON, XML) don't share a common abstraction on purpose — each keeps its own small, format-appropriate method set instead of forcing CSV, JSON and XML through one generic interface.
- API Overview for the full method list
-
Advanced Usage for typed CSV mapping (
FromCsv<T>) and generating full documents from objects