我有一个带有变量的 JSON,我需要忽略第一个数字。
{
"destinatarioDTO" : {
"cnpj" : "01377071000170"
}
}
我通过 EvaluateJsonPath 获得了变量。
我需要将结果 01377071000170
转换为 1377071000170
(删除第一位数字)。
最佳答案
您可以添加 JoltTransformJSON 处理器以及以下规范
[
{
"operation": "modify-overwrite-beta",
"spec": {
"destinatarioDTO": {
"len_cnpj": "=size(@(1,cnpj))",
"cnpj": "=substring(@(1,cnpj),1,@(1,len_cnpj))" // extract the value starting from the second character(one with the index 1) till the end of the string
}
}
},
{
"operation": "remove",
"spec": {
"destinatarioDTO": {
"len_cnpj": "" // get rid of newly generated, auxiliary attribute
}
}
}
]
关于json - Nifi - 忽略(或删除)JSON 的第一个数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74131167/