NiFi 在 JoltTransformJSON 中使用像 padRight 这样的字符串操作函数
NiFi use string manipulation function like padRight in JoltTransformJSON
我们可以在 JoltTransform 中使用像下面这样的字符串操作函数吗JSON
${BIG:padRight(5, '@')}
Link:
https://jolt-demo.appspot.com/#modify-stringFunctions
预期输出:BIG@@
就像我们使用的那样
"small_toUpper": "=toUpper(@(1,small))",
"BIG_toLower": "=toLower(@(1,BIG))",
我正在尝试,但它没有给出任何错误,但也没有给出想要的结果。还有什么其他选择。
输入JSON:
{
"x": [
3,
2,
1,
"go"
],
"small": "small",
"BIG": "BIG",
"people": [
{
"firstName": "Bob",
"lastName": "Smith",
"address": {
"state": null
}
},
{
"firstName": "Sterling",
"lastName": "Archer"
}
]
}
规格:
[
{
"operation": "modify-default-beta",
"spec": {
"y": "=join(',',@(1,x))",
"z": "=join(' ',@(1,x))",
"small_toUpper": "=toUpper(@(1,small))",
"BIG_toLower": "=toLower(@(1,BIG))",
"BIG_padding": "=padRight(@(5,BIG))"
}
}
]
您可以将 rightPad 功能与 modify-xXx-beta 一起使用 (xXx:默认或覆盖)转换如
[
{
"operation": "modify-default-beta",
"spec": {
"BIG_padding": "=rightPad(@(1,BIG),5,'@')"
}
}
]
我们可以在 JoltTransform 中使用像下面这样的字符串操作函数吗JSON
${BIG:padRight(5, '@')}
Link:
https://jolt-demo.appspot.com/#modify-stringFunctions
预期输出:BIG@@
就像我们使用的那样
"small_toUpper": "=toUpper(@(1,small))",
"BIG_toLower": "=toLower(@(1,BIG))",
我正在尝试,但它没有给出任何错误,但也没有给出想要的结果。还有什么其他选择。
输入JSON:
{
"x": [
3,
2,
1,
"go"
],
"small": "small",
"BIG": "BIG",
"people": [
{
"firstName": "Bob",
"lastName": "Smith",
"address": {
"state": null
}
},
{
"firstName": "Sterling",
"lastName": "Archer"
}
]
}
规格:
[
{
"operation": "modify-default-beta",
"spec": {
"y": "=join(',',@(1,x))",
"z": "=join(' ',@(1,x))",
"small_toUpper": "=toUpper(@(1,small))",
"BIG_toLower": "=toLower(@(1,BIG))",
"BIG_padding": "=padRight(@(5,BIG))"
}
}
]
您可以将 rightPad 功能与 modify-xXx-beta 一起使用 (xXx:默认或覆盖)转换如
[
{
"operation": "modify-default-beta",
"spec": {
"BIG_padding": "=rightPad(@(1,BIG),5,'@')"
}
}
]