如何获取跟随JSON的C#对象

时间:2016-02-24 07:27:48

标签: c# json

我有这种JSON,如何用newtonsoft转换为C#对象。

[["Newyork", "Goods & Services", "Description", "02/23/2016", "03/15/2016", "some info"]]

2 个答案:

答案 0 :(得分:5)

使用以下代码:

string jsonString = @"[[""Newyork"", ""Goods & Services"", ""Description"", ""02/23/2016"", ""03/15/2016"", ""some info""]]";

List<string[]> data = JsonConvert.DeserializeObject<List<string[]>>(jsonString);

答案 1 :(得分:1)

您可以使用JsonConvert.DeserializeObject进行此转换。如下所示:

string inputString= @"[[""Newyork"", ""Goods & Services"", ""Description"", ""02/23/2016"", ""03/15/2016"", ""some info""]]";    
List<string[]> jsonData = JsonConvert.DeserializeObject<List<string[]>>(inputString);