简体   繁体   English

Nifi - 在 Nifi 中删除我的 json 的零(00)

[英]Nifi - Remove zeros(00) of my json in Nifi

Good Night.晚安。

I need to remove the zeros of "numero":我需要删除“numero”的零:

{
  "cnpjemitente" : "48791685000168",
  "numero" : "001262851",
  "chavenfe" : "35221148791685000168550030012628511100259840",
  "serie" : "3  "
} 

The correct column:正确的列:

{
  "cnpjemitente" : "48791685000168",
  "numero" : "1262851",
  "chavenfe" : "35221148791685000168550030012628511100259840",
  "serie" : "3  "
} 

I need the leading zeros to be removed whenever possible.我需要尽可能删除前导零。

Can anyone help me?谁能帮我? Thanks谢谢

You can consecutively use the following within a JoltTransformJSON processor;您可以在JoltTransformJSON处理器中连续使用以下内容;

  • toInteger and toString functions in a modify-overwrite-beta transformation spec修改覆盖测试版转换规范中的toIntegertoString函数

  • and then remove transformation in order to get rid of the auxiliary attribute "numero_"然后删除转换以摆脱辅助属性"numero_"

such as

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "numero_": "=toInteger(@(1,numero))",// converts to 1262851(leading zeroes removed)
      "numero": "=toString(@(1,numero_))"// converts to "1262851"(quoted)
    }
  },
  {
    "operation": "remove",
    "spec": {
      "numero_": ""
    }
  }
]

or use或使用

  • toInteger and toString functions in each individual consecutive modify-overwrite-beta transformation spec每个连续的修改-覆盖-beta 转换规范中的toIntegertoString函数

such as

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "numero": "=toInteger"// converts to 1262851
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "numero": "=toString"// converts to "1262851"
    }
  }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM