我如何在 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"
}
]
}
}
谢谢大家,我只是想出我自己。这就是我所做的。
public async Task<string> CheckDevice(string id)
{
var uri = new Uri(string.Format(Constant.CheckDevicesRegistration + "id=" + id, string.Empty));
try
{
var response = await client.GetAsync(uri);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
var jsonData = (JObject)JsonConvert.DeserializeObject(result);
var message = jsonData["response"]["message"].Value<string>();
resultService = message;
}
}
catch
{
resultService = "Connection-Error";
}
return resultService;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句