转换在C#中使用.net 3.5的数据集,以JSON [英] Converting a dataset to JSON using .NET 3.5 in C#

查看:374
本文介绍了转换在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。净并检查出的 DataTable的JSON序列化的JSON.NET和JavaScriptSerializer 的在那里它被用来创建一个数据集到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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆