反序列化嵌套的complext类型..c#

反序列化嵌套的complext类型..c#,c#,json,serialization,C#,Json,Serialization,.NET 4.6.1 我有一个json字符串: { "success": true, "rows": [ { "meter_id": "10443720003987688" }] } 这是我的班级: public class ESIIDClass { public bool success { get; set; } public Rows rows { get; set; } } public class Rows { publi

.NET 4.6.1

我有一个json字符串:

{
"success": true,
"rows": [
    {
        "meter_id": "10443720003987688"
    }]
  }
这是我的班级:

public class ESIIDClass
{
    public bool success { get; set; }
    public Rows rows { get; set; }
}

public class Rows
{
    public string meter_id { get; set; }
}
我将字符串反序列化如下:

JavaScriptSerializer json_serializer = new JavaScriptSerializer();
var esiid = json_serializer.Deserialize<ESIIDClass>(theJSONstring);

如何反序列化嵌套的复杂类型?谢谢

您的类应该命名为Row,因为它代表一行(不是pural)

在json中,行显然是一个数组:

"rows": [
因此,您的课堂应该反映:

public Row[] rows { get; set; }

您的类应该命名为Row,因为它代表一行(不是pural)

在json中,行显然是一个数组:

"rows": [
因此,您的课堂应该反映:

public Row[] rows { get; set; }
你可以试试

public class ESIIDClass
{
    public bool success { get; set; }
    public Rows[] rows { get; set; }
}

公共类esidclass
{
公共bool成功{get;set;}
公共列表行{get;set;}
}
json键值对的值与
[]
将映射从
IEnumerable
继承的C类型,您可以尝试

public class ESIIDClass
{
    public bool success { get; set; }
    public Rows[] rows { get; set; }
}

公共类esidclass
{
公共bool成功{get;set;}
公共列表行{get;set;}
}

json键值对的值与
[]
将映射从
IEnumerable

继承的C#type,它不应该
是一个集合,因为它是
json
中的一个数组。JFYI:也许你应该看看Newtonsoft.json:@MartinParkin-yep..我将行更改为这个公共列表行{get;set;}它是有效的。Thankshouldn
Rows
不应该是一个集合,因为它是
JSON
中的一个数组?JFYI:也许你应该看看Newtonsoft.JSON:@MartinParkin-yep。谢谢