這是我的測試數據:如何指示特定的JSON路徑?
{
"errorCode": null,
"errorMessage": null,
"responseItems": [
{
"errorCode": null,
"errorMessage": null,
"personId": "FCC2",
"personCode": "SUNEETHA",
"personFirstName": "suneetha",
"personLastName": "Durgam",
"office": "London",
"officeCode": "L",
"department": "Product",
"departmentCode": "PR",
"subDepartment": "QA",
"subDepartmentCode": "QA",
"timeOffStaffSummaryDTO": [
{
"officeCode": null,
"startMonthYear": null,
"endMonthYear": null,
"personId": null,
"alphaId": null,
"continent": null,
"allowancesIntotal": 20,
"allowancesUsed": 0,
"allowancesSubmitted": 0,
"allowancesApproved": 0,
"allowancesRemaining": 20,
"timeOffType": {
"id": 4001,
"continent": "EU",
"alphaId": "9J",
"code": "PTO",
"description": "Personal Time Offdd",
"account": "MADMIN",
"colourCode": "#CCCCCC",
"approvalRequired": true,
"commentRequired": false,
"paid": true
},
"timeOffTypeWithoutAllowance": false
}
]
}
]
}
我試圖去使用此路徑的Timeoff類型描述:
$.responseItems[0].timeOffStaffSummaryDTO[0].timeOffType.description
現在,這適用於任何JSON路徑測試我在網上嘗試,但該模板不會在頁面標題欄中顯示此值。
在重複細節帶,我也試圖顯示此:
$.responseItems.timeOffStaffSummaryDTO[0].timeOffTypeWithoutAllowance
試了一下沒有$符號或第一點,沒有什麼區別,它總是顯示爲空。我也嘗試過在字段描述中或作爲屬性「net.sf.jasperreports.json.field.expression」的值。
我錯過了什麼?
許多,非常感謝 - 特別是花時間顯示代碼和輸出!我的查詢定義是正確的,但我的字段定義已關閉 - 我需要擺脫.responseItems位。使用JSONPath非常新,直到現在才處理xml數據。 – user2668539
@ user2668539您的歡迎,感謝您的接受 –