Skip to content

Getting Started

Marcus Ackre Medina edited this page Sep 13, 2026 · 3 revisions

Getting Started

Install

dotnet add package MarcusMedina.Fluent.Data

Requires .NET 10+

Import

using MarcusMedina.Fluent.Data.Extensions;

CSV

// 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[]>

JSON

// 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 }

XML

"<b>bold</b>".ToXmlContent();     // "&lt;b&gt;bold&lt;/b&gt;"
"&lt;tag&gt;".FromXmlContent();   // "<tag>"

The core idea

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.

Next steps

  • API Overview for the full method list
  • Advanced Usage for typed CSV mapping (FromCsv<T>) and generating full documents from objects

Clone this wiki locally