当我通过 API 进行网络调用时,它会显示一个 JSON 文件。选择我想要的某些数据没有问题。对于这个项目,我们不想这样做。我们希望得到任何状态 = 1 的结果并显示该计数。
List<stats> ls = new List<stats>();
ls = rClient.makeRequest(txtURL1.Text);
listBox1.DataSource = ls;
listBox1.DisplayMember = "fullResult";
var url = ls[1].ID;
string access = ls[1].FirstAccessed;
string endAccess = ls[1].LastAccessed;
string count = ls.Count.ToString();
string status = ls[int.Parse(count)- 1].Status;
string intCon = url.ToString();
dataOutput.Text = intCon + " " + access + " " + endAccess + " " + count + " " + status;
如您所见,我选择了 JSON 文件的不同部分。我确实试图尝试获取一些信息,但我的结果并不好。我需要一些指导。刚开始玩C#。
ListBox 显示来自 API 的所有内容,因此我有点想读取所有数据并以这种方式提取单独的状态代码。
JSON 输出
[
{
"ID": 502,
"WorkflowID": "5b7ac3e66eb51a0dcc287f84",
"WorkflowName": "I9 Approval",
"EngineID": null,
"FilePages": null,
"PortalID": 0,
"Permissions": 0,
"ProcessActions": null,
"SSDocument": {
"SSDBID": 1002,
"SSArchiveID": 1,
"SSDocumentID": 164
},
"LastAccessed": "2018-11-28T17:34:38.843Z",
"FirstAccessed": "2018-11-28T17:34:38.843Z",
"Status": 3, **<--- Want to read this here.**
"CurrentNode": "-7",
"Wait": 0,
"WaitStart": "0001-01-01T00:00:00Z",
"Queue": null,
"Properties": [
在此处解析 JSON:
public List<stats> makeRequest(string endPoint)
{
string strResponseVlaue = string.Empty;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endPoint);
request.Method = httpMethod.ToString();
request.Method = "GET";
request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes("SSAdministrator:Password!"));
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
API 中还有 47 个其他结果。
宝慕林4294392
相关分类