使用打字稿从数组json响应中捕获数据
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用打字稿从数组json响应中捕获数据相关的知识,希望对你有一定的参考价值。
{
"items": [
{
"ContestId": 300100183354726,
"ContestNumber": "CDRM_11102",
"ContestName": "New Contest 58428129",
"Description": null,
"OwnerId": 100010032636167,
"StartDate": "2019-12-12T00:00:00+00:00",
"EndDate": "2019-12-22T00:00:00+00:00",
"KPIId": 300100180907483,
"CreatedBy": "SALES_MGR",
"CreationDate": "2019-12-12T09:24:26+00:00",
"LastUpdatedBy": "SALES_MGR",
"LastUpdateDate": "2019-12-12T09:24:26.081+00:00",
"LastUpdateLogin": "94FD310D04952F1BE05369B3F20A9266",
"ObjectVersionNumber": 1,
"ConflictId": 0,
"OwnerName": "Todd Beeler",
"OwnerNumber": "100010032636167",
"OwnerUniqueName": "Todd Beeler",
"KPIName": "Appointments Completed",
"KPINumber": "CDRM_6",
"KPIDescription": null
}
],
"count": 1,
"hasMore": false,
"limit": 25,
"offset": 0,
"links": [
{
"rel": "self",
"href": "https://fuscdrmsmc217-fa-ext.us.oracle.com:443/crmRestApi/resources/11.13.18.05/contests",
"name": "contests",
"kind": "collection"
}
],
}
当我尝试:
contestNumber = await restResponce.responceJSON["items[1].ContestNumber"]
结果不确定。请帮助我如何获取比赛编号。
我的图书馆:
export let restResponce = {
"responceJSON" : {},
"responceCODE" : 0,
"responceTEXT" : "",
"requestedValues" : {}
};
答案
尝试:
var json = JSON.parse(JSON.stringify(response));document.write(json.items [0] .ContestNumber);
这应该工作!
以上是关于使用打字稿从数组json响应中捕获数据的主要内容,如果未能解决你的问题,请参考以下文章