如何使用 .NET 和 C# 将数据集对象转换为 JSON 对象?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15359701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 16:30:12  来源:igfitidea点击:

How to convert a dataset object to a JSON object using .NET and C#?

c#.netjsonasp-classicdataset

提问by Amol

I'm getting data into a dataset object from a database and then on the server side I want to bind the dataset to the jQuery table, but the table accepts a JSONobject.

我将数据从数据库获取到数据集对象中,然后在服务器端我想将数据集绑定到 jQuery 表,但该表接受一个JSON对象。

How do I convert the DataSet object into JSON to pass through to the jQuery table?

如何将 DataSet 对象转换为 JSON 以传递到 jQuery 表?

采纳答案by Zaki

You can use Newtonsofts Json.Netand see this examplewhich is using datatable serialization to JSON.

您可以使用Newtonsofts Json.Net并查看此示例该示例使用数据表序列化到 JSON。