Converter

PrettyPrintTo

PrettyPrintTo takes whatever the current input produces and reformats it for readability. It does not change the data - only the whitespace. The result is written to the out string parameter. Use it for logging, debugging output, displaying data in a UI, or producing human-readable files.

NOTE

PrettyPrintTo produces the same content as SaveTo(ref string) but with added indentation. For formats that do not support pretty-printing (CSV, TAB, PIPE, BASE64), the output is identical to RenderTo.

Examples

GPAL Fluent: High-level fluent C# API

//PrettyPrintTo is a terminal call like SaveTo and RenderTo - it executes the conversion and returns. The out string parameter receives the formatted output.

// Pretty-print a compact JSON string

string pretty;

GPAL.Converter

.WithInput(compactJson)

.WithInputType(DataFormat.JSON)

.PrettyPrintTo(out pretty);

Console.WriteLine(pretty);


// Pretty-print XML loaded from a file

GPAL.Converter

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

.PrettyPrintTo(out pretty);

💬 Ask GPAL