[英]Parse JSON string into DataSet
I have to the replication.That time have to pass String as JSON 我必须进行复制。那个时候必须将String作为JSON传递
{"Table1" :
[
{"Name" : "MyCustomer","Description" : "cutomer","Status" : "1"}, {"Name" : "Kiraa","Description" : "My","Status" : "1",}
]
}
This is my format of JSON result. 这是我的JSON结果格式。 I want to convert to DataSet.
我想转换为数据集。
I have installed JSON.NET library. 我已经安装了JSON.NET库。 I am using C#.net
我正在使用C#.net
public bool convertJSONToDataSet(string strBusinessUnit, string strExecutiveCode, string strTableName, String jsonContent)
{
DataSet dataset = JsonConvert.DeserializeObject<String>(jsonContent);
return true;
}
here this statement is wrong DataSet dataset = JsonConvert.DeserializeObject<String>(jsonContent);
这里的语句是错误的
DataSet dataset = JsonConvert.DeserializeObject<String>(jsonContent);
.What is the issue. 问题是什么。 Please tell me how to covert to a JSON string to a Dataset.
请告诉我如何将JSON字符串转换为数据集。
You'd have to create an object to deserialize to. 您必须创建一个要反序列化的对象。
class Customer
{
public String Name { get; set; }
public String Description { get; set; }
public int Status { get; set; }
}
You can then deserialize objects like this: 然后可以像这样反序列化对象:
Customer customer = JsonConvert.DeserializeObject<Customer>(jsonContent);
As far as I'm concerned, you can then add multiple Customer
objects into a list, dataset or whatever you like. 就我而言,您可以将多个
Customer
对象添加到列表,数据集或任何您喜欢的对象中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.