- 已关闭**。此问题需要超过focused。当前不接受答案。
- 想要改进此问题吗?**更新此问题,使其仅关注editing this post的一个问题。
6小时前关门了。
Improve this question
我有以下JSON对象
{
"JOBS": [{
"JOBNAME": "Online VAT Reporting for Spain",
"JOBPATH": "/oracle/apps/ess/financials/europeanLocalizations/financialReporting",
"REQUESTID": "1234",
"STATUS": "SUCCEEDED",
"CHILD": [{
"JOBNAME": "Collections for the Issued Invoices Register",
"JOBPATH": "/oracle/apps/ess/financials/europeanLocalizations/financialReporting",
"REQUESTID": "5678",
"STATUS": "SUCCEEDED"
}, {
"JOBNAME": "Invoices for the Issued Invoices Register",
"JOBPATH": "/oracle/apps/ess/financials/europeanLocalizations/financialReporting",
"REQUESTID": "0923444",
"STATUS": "SUCCEEDED"
}]
}, {
"JOBNAME": "Upload Interface Error and Job Output File to Universal Content Management",
"JOBPATH": "/oracle/apps/ess/financials/commonModules/shared/common/interfaceLoader",
"REQUESTID": "0939393",
"STATUS": "SUCCEEDED"
}],
"SUMMARYSTATUS": "SUCCEEDED",
"DOCUMENTID": "4848488",
"DOCUMENTNAME": "XXXX_OnlineVatReporting_1897731"
}
使用javascript,我想提取具有"JOBNAME":"Invoices for the Issued Invoices Register"
的子节点的REQUESTID
在本例中是0923444
。
谁能告诉我如何获得REQUESTID
?
3条答案
按热度按时间ctrmrzij1#
我建议阅读更多关于内置数组方法的内容,比如find:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
但这应该可以
jhdbpxl92#
检查以下内容:
ehxuflar3#
一种方法是:
1.首先使用JSON.parse()将JSON字符串解析为JavaScript对象。
1.然后,循环JOBS数组以查找具有**“JOBNAME”的作业:“Invoices for the Issued Invoices Register”。
1.找到后,将其REQUESTID值存储在requestId变量中。
1.最后,当输出requestId**变量到控制台时,您可以得到您想要的。