嗨,我想反序列化这个Json:
{
"engine_name": "Hermle",
"criterion": {
"squareness": {
"name": "perpendicularité",
"theoretical": "5",
"expected": "5"
},
"backlash": {
"name": "jeu à l'inversion",
"theoretical": "5",
"expected": "5"
},
"straightness": {
"name": "rectitude",
"theoretical": "1",
"expected": "1"
},
"spindle-runout": {
"name": "faux rond broche",
"theoretical": "5",
"expected": "5"
},
"circularity": {
"name": "circularité",
"theoretical": "5",
"expected": "5"
}
}
}
我有我的课对象:
public class SmartDevice
{
public string Engine_name { get; set; }
public Object criterion { get; set; }
}
这很好用,但是我无法为条件对象提供计数属性,因此我想列出条件列表,但我不知道该怎么做。
答案 0 :(得分:2)
您可以使用Dictionary<string, object>
,也可以使用object
之类的自定义类型来代替CriteriaObject
。
答案 1 :(得分:0)
在定义问题时,不可能从条件中获取计数,因为它是对象而不是列表或数组。 为了拥有条件列表,您需要这样的东西:
{
"engine_name": "Hermle",
"criterion": [
{
"type": "squareness",
"name": "perpendicularité",
"theoretical": "5",
"expected": "5"
},
{
"type": "circularity",
"name": "circularité",
"theoretical": "5",
"expected": "5"
}
]
}
该类应如下所示:
public class SmartDevice
{
public string Engine_name { get; set; }
public List<Object> criterion { get; set; }
}