【发布时间】:2017-04-12 21:41:44
【问题描述】:
我有这样的 JSON:
{"rows":
{
"1":{"rowNumber":1,"productID":"100"},
"2":{"rowNumber":2,"productID":"101"},
"3":{"rowNumber":3,"productID":"102"}
}
}
我需要建立领域模型。
例如:
class Row
{
public int rowNumber{get; set;}
public string productID{get; set;}
}
根对象
class RootObject
{
public ? ? rows {get; set;}
}
什么样的类型必须是 rows 属性?
【问题讨论】:
-
“以数字为类型”是什么意思?你的问题不清楚
-
将您的
"rows"属性设为Dictionary<string, Row>。见Create a strongly typed c# object from json object with ID as the name 和How can I parse a JSON string that would cause illegal C# identifiers?。 -
-> dbc: 将你的评论设为 answear,我将标记为正确的 answear