Converter

SaveTo

SaveTo has five overloads covering every output destination. SaveTo(GPALFile) writes serialized output to disk. SaveTo(IGPALDatabase) inserts converted rows into a database table. SaveTo(ref IGPALGrid<string>) populates an in-memory grid. SaveTo(string) writes to a string variable. SaveTo<T>(ref T) is the most powerful - it deserializes the input into a strongly-typed C# class, automapping all fields and properties without any manual mapping code. When the target class contains nested types, call RegisterKnownStructType first.

NOTE

If your target class contains nested custom structs or complex types, call RegisterKnownStructType(typeof(MyNestedType)) before WithInput in the chain. Standard .NET types are handled automatically.

Examples

GPAL Fluent: High-level fluent C# API

//All five SaveTo overloads execute the conversion immediately - there is no deferred execution. The chain is complete as soon as SaveTo returns.

// To a file

GPAL.Converter

.WithInput(GPAL.FileFor("data.csv"))

.WithFirstLineHasColumnNames(true)

.WithOutputType(DataFormat.JSON)

.SaveTo("data.json");


// To a typed class - zero mapping code

var customer = new Customer();

GPAL.Converter

.WithInput(GPAL.FileFor("customer.json"))

.WithOutputType(DataFormat.CLASS)

.SaveTo<Customer>(ref customer);


// To an in-memory grid

var grid = GPAL.Grid.ToGPALObject();

GPAL.Converter

.WithInput(GPAL.FileFor("records.csv"))

.WithFirstLineHasColumnNames(true)

.SaveTo(ref grid);

💬 Ask GPAL