Cast values to string in Json Path Expression in Azure Data Factory copy activity

半世苍凉 提交于 2020-04-30 07:06:04

问题


I have an input JSON file where the actual value of the property could be either a numeric value or a string.I extract the value by specifying a json path expression like

"fieldValue": "values[*].value"

in the azure data factory copy activity, connection tab for the source.

Since the actual field value in the JSON could be something like "X" or 2.34 it is not able parse it all into strings even though in the schema I specify the fieldValue as string.

So is there a way I could cast it so that it would take the string as is in case the value is "X" and if its 2.34 convert it to "2.34"

"fields" : "[{"fieldId":"fieldName", "values": [{value: 2.34}]},....}]"

回答1:


You can use expressions in the value field. Here's expression and functions in ADF doc.

Example usage:

"field": {
    "value": "@string(your_value)",
    "type": "Expression"
}

And on the ADF visual tool, there's a "add dynamic content" link below each field. Expressions, functions and system variables can be dynamically added there.



来源:https://stackoverflow.com/questions/49732768/cast-values-to-string-in-json-path-expression-in-azure-data-factory-copy-activit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!