数据工厂 - 从 JSON 文件中使用破折号“-”的字段检索值

Data Factory - Retrieve value from field with dash "-" from JSON file

在我的管道中,我通过 REST API 使用 GET 请求到达第 3 方数据库。作为输出,我收到一堆 JSON 文件。我必须下载的 JSON 个文件的数量(与我必须使用的迭代次数相同)在 JSON 文件中的一个字段中。问题是该字段的名称是 'page-count',其中包含“-”。

@activity('Lookup1').output.firstRow.meta.page.page-count

数据工厂将字段名称中的破折号视为减号,因此我收到错误而不是该字段的值。

{"code":"BadRequest","message":"ErrorCode=InvalidTemplate, ErrorMessage=Unable to parse expression 'activity('Lookup1').output.firstRow.meta.page.['page-count']'","target":"pipeline/Product_pull/runid/f615-4aa0-8fcb-5c0a144","details":null,"error":null}

JSON 文件的结构如下所示:

 "firstRow": {
        "meta": {
            "page": {
                "number": 1,
                "size": 1,
                "page-count": 7300,
                "record-count": 7300
            },
            "non-compliant-record-count": 7267
        }
    },
    "effectiveIntegrationRuntime": "intergrationRuntimeTest1",
    "billingReference": {
        "activityType": "PipelineActivity",
        "billableDuration": [
            {
                "meterType": "SelfhostedIR",
                "duration": 0.016666666666666666,
                "unit": "Hours"
            }
        ]
    },
    "durationInQueue": {
        "integrationRuntimeQueue": 1
    }
}

如何解决这个问题?

以下语法在检索带有连字符的 json 元素的值时有效。否则,解析器会将其视为减号。它似乎没有被微软记录下来,但是我设法通过我的一个项目的反复试验让它工作。

@activity('Lookup1').output.firstRow.meta.page['page-count']

这对我们也有用。我们遇到了同样的问题,我们无法引用包含破折号 (-) 的输出字段。我们引用了这个 post 并使用了方括号和单引号,它起作用了!

示例如下。

@activity('get_token').output.ADFWebActivityResponseHeaders['Set-Cookie']