【发布时间】:2019-10-24 06:21:55
【问题描述】:
如何在 c# 中解析这个没有类的 json。我不知道该使用数组还是其他任何东西。
这是我要解析的json结果
{
"success": true,
"status": 200,
"message": "SUCCESS",
"response": {
"message": "Device Registered",
"data": [
{
"ID": "607dbb9e08b4c22a",
"Type_ID": "657911C6-AFA5-4AC4-922F-39E56CCB28CC",
"Name": "Genymotion Google Nexus 5X",
"Active": "1",
"Insert_User": "Default",
"Insert_Date": "2019-10-18 16:33:01.650",
"Update_User": "Default",
"Update_Date": "2019-10-18 16:33:01.650"
}
]
}
}
【问题讨论】:
-
你可以使用 linq-to-json。
-
阅读
JObject。这就是你需要的。 newtonsoft.com/json/help/html/… -
如果您只需要一个值,请按照建议进行操作,如果您想节省时间和代码,则只需将其反序列化为具体类(以实际节省时间和代码)跨度>
-
我同意@TheGeneral,为您的 JSON 数据生成类。这将需要 5 分钟,但将来会为您节省大量时间。
标签: c# json serialization