首页 > 解决方案 > ADF 中的集合和附加变量中的引号和特殊字符问题

问题描述

我正在尝试使用 set 和 append 变量准备一个变量值,该变量需要传递到复制活动的请求正文以从 API 获取数据。我需要一次从数据库中查找 100 个值并形成一个值数组,但是由于复制活动失败,“(引用)值被附加在值的开始、结束和中间。我是截至目前尝试前两个值。"[\"{\\\"RIC\\\":{\\\"Value\\\":\\\"FHN.N\\\"}}\",\"{\\\"RIC\\\":{\\\"Value\\\":\\\"0142.HK\\\"}}\"]"这是我得到的最终变量输出,我使用 @replace(string(variables('RIC')),'',' 删除了额外的 \ (斜杠) ') 并且输出是 -"[\"{\"RIC\":{\"Value\":\"FHN.N\"}}\",\"{\"RIC\":{\"Value\":\"0142.HK\"}}\"]"由于“在两个 RIC 值之间和 }] 之间的引号在开始和结束时失败。如果我可以得到输出为 "[{"RIC":{"Value":"FHN.N" }},{"RIC":{"Value":"0142.HK"}}]" 它将解决问题,因为我尝试手动传递它。

在复制活动中传递的请求正文 - "{"GetSignificantDevelopments_Request_1":{"FindRequest":{"CompanyIdentifiers_typehint":["CompanyIdentifiers","CompanyIdentifiers"],"CompanyIdentifiers":["{"RIC":{"Value":" FHN.N"}}","{"RIC":{"Value":"0142.HK"}}"],"StartDate":"2021-01-05T00:00:00","EndDate":" 2021-01-06T00:00:00","Significance":"1 2 3","MaxNumberOfItems": 100}}}",-这是失败的

手动尝试成功的请求正文 - "{"GetSignificantDevelopments_Request_1":{"FindRequest":{"CompanyIdentifiers_typehint":["CompanyIdentifiers","CompanyIdentifiers"],"CompanyIdentifiers":[{"RIC":{"Value":"FHN. N"}},{"RIC":{"Value":"0142.HK"}}],"StartDate":"2021-01-05T00:00:00","EndDate":"2021-01-06T00 :00:00","意义":"1 2 3","MaxNumberOfItems": 100}}}",

标签: azureazure-data-factoryazure-data-factory-2

解决方案


The other way would be to use Replace function to replace all unwanted characters from the variable like : @replace(string(variables('RIC')),'','') where \ is just one of the characters. You can keep on concatenating replace functions to replace other characters and achieve your output. Hope this would be helpful :)


推荐阅读