【发布时间】:2022-11-25 16:53:53
【问题描述】:
我是 JSONPath 的新手,想编写一个仅在满足特定条件时才检索属性值的 JSONPath 语法。我所追求的值不是数组的一部分,但我已经设法在以下 JSONPath 工具中进行过滤:https://www.site24x7.com/tools/json-path-evaluator.html
给定以下 JSON,如果 column2.attributeId 等于 B0,我只想提取 column2.dimValue 的值:
{
"batchId": 279,
"companyId": "40",
"period": 202208,
"taxCode": "1",
"taxSystem": "",
"transactionDate": "2022-08-05T00:00:00.000",
"transactionNumber": 222006089,
"transactionType": "IF",
"year": 2022,
"accountingInformation": {
"account": "4010",
"column1": {
"attributeId": "H9",
"dimValue": "76"
},
"column2": {
"attributeId": "B0",
"dimValue": "2170103"
},
"column3": {
"attributeId": "",
"dimValue": ""
},
"column4": {
"attributeId": "BF",
"dimValue": "217010330"
},
"column5": {
"attributeId": "10",
"dimValue": "3101"
},
"column6": {
"attributeId": "06",
"dimValue": ""
},
"column7": {
"attributeId": "19",
"dimValue": "K"
}
},
"categories": {
"cat1": "H9",
"cat2": "B0",
"cat3": "",
"cat4": "BF",
"cat5": "10",
"cat6": "06",
"cat7": "19",
"dim1": "76",
"dim2": "2170103",
"dim3": "",
"dim4": "217010330",
"dim5": "3101",
"dim6": "",
"dim7": "K"
},
"amounts": {
"amount": 48.24,
"amount3": 0.0,
"amount4": 0.0,
"currencyAmount": 48.24,
"currencyCode": "NOK",
"debitCreditFlag": 1
},
"invoice": {
"customerOrSupplierId": "58118",
"description": "",
"externalArchiveReference": "",
"externalReference": "2170103",
"invoiceNumber": "220238522",
"ledgerType": "P"
},
"additionalInformation": {
"number": 0,
"orderLineNumber": 0,
"orderNumber": 0,
"sequenceNumber": 1,
"status": "",
"value": 0.0,
"valueDate": "2022-08-05T00:00:00.000"
},
"lastUpdated": {
"updatedAt": "2022-09-05T10:59:11.633",
"updatedBy": "HELVES"
}
}
我使用了这个 JSONPath 语法:
$['accountingInformation']['column2'][?(@.attributeId=='B0')].dimValue
这给出了以下结果:
[
"2170103"
]
我在 Azure 数据工厂映射中使用了这个结果,它似乎不起作用,因为结果是一个数组。
谁能帮我解决它只返回实际值的语法?这可能吗?
【问题讨论】:
-
如何在 ADF 中映射?你能分享截图吗?