azure - 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}}}",
解决方案
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 :)
推荐阅读
- mysql - LibreOffice Base 数据透视表以获得更好的报告,无需计算值
- android - 找不到路径“/content:/com.android.externalstorage.documents/document/6759-130B%3ANew%20Text%20Document.txt”的一部分
- python-3.x - python 3.8 flask apache 2.4 wsgi multiprocessing RuntimeError: fork not supported for subinterpreters
- c# - Quartz 作业不能使用 autofac 和带有服务的构造函数运行
- webpack - Workbox-webpack-plugin 对我来说不能离线工作
- python - 使用 BS4 构造最短的有效 css 选择器
- python - google colab pytorch 版本错误(课程 231n)
- java - Java sublime.build 在一个目录中工作,但在另一个目录中不工作
- javascript - Javascript:轮播活动点和左右按钮
- kubernetes - 禁止:用户,“代码”:使用 curl 访问 kube-apiserver 时出现 403 错误