Converting a dataset to JSON using .NET 3.5 in C#(在 C# 中使用 .NET 3.5 将数据集转换为 JSON)
问题描述
我一直在寻找一种简单的方法将数据集从 PostgreSQL 数据库转换为JSON 用于我正在构建的项目中.
I have been searching for a simple way to convert a dataset from a PostgreSQL database to JSON for use in a project that I am building.
这是我第一次使用 JSON,我发现找到一个简单的方法来做这件事真的很棘手.目前我一直在使用 StringBuilder 从数据集中的信息创建 JSON 字符串,但我听说使用 .NET 3.5 使用 System.Runtime.Serialization
命名空间,虽然我还没有找到一篇关于这是如何实现的简单文章或博客完毕!最简单的方法是什么?
This is my first time using JSON, and I have found it really tricky to find a simple way of doing this. I have been using a StringBuilder at the moment to create a JSON string from the information in the dataset, but I have heard that it is possible to do this very simply with .NET 3.5 using the System.Runtime.Serialization
namespace, though I have yet to find a simple article or blog on how this is done! What is the easiest way to do this?
推荐答案
使用 Newtonsofts Json.Net 并查看 DataTable JSON 序列化 JSON.NET 和 JavaScriptSerializer 用于创建 DataSet-to-JSON 转换器.
Use Newtonsofts Json.Net and check out DataTable JSON Serialization in JSON.NET and JavaScriptSerializer where it's used to create a DataSet-to-JSON converter.
这篇关于在 C# 中使用 .NET 3.5 将数据集转换为 JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 C# 中使用 .NET 3.5 将数据集转换为 JSON


- WebMatrix WebSecurity PasswordSalt 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01