Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active February 15, 2023 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/499489bd99efab8b475e447083d377a6 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/499489bd99efab8b475e447083d377a6 to your computer and use it in GitHub Desktop.
Convert JSON to CSV & CSV to JSON using C#
// Convert CSV file to JSON format in C#
var loadOptions = new CsvLoadOptions
{
Separator = ','
};
using (Converter converter = new Converter(@"path/sample.csv", ()=> loadOptions))
{
WebConvertOptions options = new WebConvertOptions
{
Format = WebFileType.Json
};
converter.Convert(@"path/CsvToJSON.json", options);
}
// Convert JSON files to CSV format in C#
using (Converter converter = new Converter(@"path/sample.json"))
{
SpreadsheetConvertOptions options = new SpreadsheetConvertOptions()
{
Format = SpreadsheetFileType.Csv
};
converter.Convert(@"path/JsonToCSV.csv", options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment