问题
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