[英]Json deserializeObject
嗨,我想反序列化此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; }
}
這很好用,但我無法為條件對象提供計數屬性,因此我想擁有一個條件列表,但我不知道該怎么做。
您可以使用Dictionary<string, object>
也可以使用像CriteriaObject
這樣的自定義類型來代替object
。
定義問題時,不可能從條件中獲取計數,因為它是對象而不是列表或數組。 為了擁有條件列表,您需要以下內容:
{
"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; }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.