在数据工厂中查找 Activity 和 ForEach - 处理嵌套的 JSON 值

Lookup Activity and ForEach in Data Factory - Processing Nested JSON Values

我想了解是否可以读取数据工厂中嵌套的 JSON 值。我查找 activity 后跟一个 for each 以处理查找中的值。对于简单的 json 对象,我可以使用 '@activity('lu_config_readentities').output.value' 读取 for each 中的值。

使用下面的示例 JSON 值,我可以使用 @item().Query 读取查询值,但是 @item.Query.Term 失败并出现错误。

这是已知的限制吗?无论如何我可以读取这些值吗?

JSON Sample: 

{
    "count": 1,
    "value": [
        {
            "Id": 63,
            "Source": "xxx",
            "EntityName": "test",
            "Query": {
                        "Term":"science",
                        "Database":"nih"
                     }
        }
    ],
    "effectiveIntegrationRuntime": "DefaultIntegrationRuntime (Central US)",
    "billingReference": {
        "activityType": "PipelineActivity",
        "billableDuration": [
            {
                "meterType": "AzureIR",
                "duration": 0.016666666666666666,
                "unit": "DIUHours"
            }
        ]
    },
    "durationInQueue": {
        "integrationRuntimeQueue": 11
    }
}

Error output: 

  "message": "The expression 'item().Query.Term' cannot be evaluated because property 'Term' cannot be selected. Property selection is not supported on values of type 'String'.",
    "failureType": "UserError",
    "target": "Set variable1"

你可以按照下面的步骤,我可以成功获取嵌套的值json。

这是我的查询activity:

然后就可以直接用name取值了:

这是你的 json:

{
            "Id": 63,
            "Source": "xxx",
            "EntityName": "test",
            "Query": {
                        "Term":"science",
                        "Database":"nih"
                     }
}

这是我这边查找 activity 的输出:

{
    "firstRow": {
        "Id": 63,
        "Source": "xxx",
        "EntityName": "test",
        "Query": {
            "Term": "science",
            "Database": "nih"
        }
    },
    "effectiveIntegrationRuntime": "DefaultIntegrationRuntime (Central US)",
    "billingReference": {
        "activityType": "PipelineActivity",
        "billableDuration": [
            {
                "meterType": "AzureIR",
                "duration": 0.016666666666666666,
                "unit": "DIUHours"
            }
        ]
    },
    "durationInQueue": {
        "integrationRuntimeQueue": 10
    }
}

表达式应该是(在我这边,查找 activity 被命名为 Lookup1):

activity('Lookup1').output.firstRow.Query.Term

我这边可以取值成功,请你这边试试