Generically Flatten Json using c#

前端 未结 7 1685
闹比i
闹比i 2020-11-30 02:21

I want to generically flatten some json so I can convert to a datatable and bind to a datagrid using c#

What is the best way of doign it, bearing in mind I dont know

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 03:08

    Here is one another way to flatten JSON / convert to DataTable using Cinchoo ETL

    Flatten JSON:

    using (var r = new ChoJSONReader("*** JSON file path ***"))
    {
        foreach (var rec in r.Select(f => f.Flatten()))
            Console.WriteLine(rec.Dump());
    }
    

    JSON to DataTable:

    using (var r = new ChoJSONReader("*** JSON file path ***"))
    {
        var dt = r.AsDataTable();
        Console.WriteLine(dt.DumpAsJson());
    }
    

提交回复
热议问题