csvhelper

JSON string to CSV and CSV to JSON conversion in c#

佐手、 提交于 2019-11-27 04:17:52
I'm working with JSON/CSV files in my asp.net web API project and tried with CSVHelper and ServiceStack.Text libraries but couldn't make it work. The JSON file containing an array is dynamic and may have any number of fields I read the file using streamreader and then need to convert it into CSV file to make it downloadable for end users. example file text [{"COLUMN1":"a","COLUMN2":"b","COLUMN3":"c","COLUMN4":"d","COLUMN5":"e"}, {"COLUMN1":"a","COLUMN2":"b","COLUMN3":"c","COLUMN4":"d","COLUMN5":"e"}] JSON to CSV public static string jsonStringToCSV(string content) { var jsonContent = (JArray

JSON string to CSV and CSV to JSON conversion in c#

穿精又带淫゛_ 提交于 2019-11-26 22:14:14
问题 I'm working with JSON/CSV files in my asp.net web API project and tried with CSVHelper and ServiceStack.Text libraries but couldn't make it work. The JSON file containing an array is dynamic and may have any number of fields I read the file using streamreader and then need to convert it into CSV file to make it downloadable for end users. example file text [{"COLUMN1":"a","COLUMN2":"b","COLUMN3":"c","COLUMN4":"d","COLUMN5":"e"}, {"COLUMN1":"a","COLUMN2":"b","COLUMN3":"c","COLUMN4":"d",