使用json将数据表转换为json.网 [英] converting data table to json using json. net
本文介绍了使用json将数据表转换为json.网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用json.net将数据表转换为json对象.
I want to convert my data table to json object using json.net
推荐答案
试试这个
如果要使用Json.NET,则必须将其安装在项目中.Json.NET可以作为NuGet软件包使用,也可以使用管理NuGet软件包进行安装.
导入以下命名空间:
使用Newtonsoft.Json;
Try this
If you want use Json.NET, you must install it in your project.Json.NET is available as a NuGet package and can be installed using the Manage NuGet Packages.
Import the following namespace:
using Newtonsoft.Json;
DataTable dt = new DataTable();
da.Fill(dt);
string JSONresult;
JSONresult = JsonConvert.SerializeObject(dt);
Response.Write(JSONresult);
请参考:-在asp.net C#中将数据表转换为json对象
Refer:- convert datatable to json object in asp.net C#
请阅读我对问题的评论.你什么都没做!您是否尝试过通过Google搜索?您可以在此处找到大量示例,例如:
http://stackoverflow.com/questions/17398019/how- to-convert-datatable-to-json-in-c-sharp [ http://stackoverflow.com/questions/13326777/c-sharp-datatable-to-json [ ^ ]
将ASP.NET DataTable转换为JSON,以便使用JavaScript中的数据表 [ ^ ]
Please, read my comment to the question. You did nothing! Have you tried to search via Google? Tons of examples you can find there, for example:
http://stackoverflow.com/questions/17398019/how-to-convert-datatable-to-json-in-c-sharp[^]
http://stackoverflow.com/questions/13326777/c-sharp-datatable-to-json[^]
Convert ASP.NET DataTable to JSON, to use a DataTable in JavaScript[^]
这篇关于使用json将数据表转换为json.网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文