Last active
February 15, 2023 12:48
-
-
Save GroupDocsGists/499489bd99efab8b475e447083d377a6 to your computer and use it in GitHub Desktop.
Convert JSON to CSV & CSV to JSON using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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