将Nifi中的列分成两列(数组)。

huangapple go评论64阅读模式
英文:

Nifi - Separate the column in two colums (Array)

问题

I can help you with the translation part. Here's the translation of the provided text:

我有一个 JSON:

{
  "consultor_do_projeto": [
    "Iago de Oliveira",
    "Murilo Tavares"
  ]
}

我需要转换成:

{
  "consultor0" : "Iago de Oliveira",
  "consultor1" : "Murilo Tavares"
}

 Jolt 规范中,我可以这样做吗?

如果第三项存在,它将是 `consultor2`

感谢您的帮助!
英文:

I have a JSON :

{
  "consultor_do_projeto": [
    "Iago de Oliveira",
    "Murilo Tavares"
  ]
}

I need to transform in:

{
  "consultor0" : "Iago de Oliveira",
  "consultor1" : "Murilo Tavares"
}

In Jolt Spec, Can I do this?

if the third item exists, it will be the consultor2

Thanks to help!

答案1

得分: 3

是的,您可以通过使用Jolt规范来实现,例如:

[
  {
    "operation": "shift",
    "spec": {
      "*_do_projeto": {
        "*": {
          "@": "&(2,1)"
        }
      }
    }
  }
]

其中:

  • &(2,1) 从上面的2级中提取第1个星号的替换内容(例如,子字符串 "consultor")

以及

  • & 旁边的内容提取了与 @ 符号对应的索引值(0,1,..)的数组中的值。

网站http://jolt-demo.appspot.com/上的演示如下:

将Nifi中的列分成两列(数组)。

英文:

Yes, you can do through use of a Jolt spec such as

[
  {
    "operation": "shift",
    "spec": {
      "*_do_projeto": {
        "*": {
          "@": "&(2,1)&"
        }
      }
    }
  }
]

where

  • &(2,1) brings the 1st asterisk replacement from the 2 levels up (eg. the substring "consultor")

and

  • & next to that brings the counterpart value for @ sign which refers the indexes (0,1,..) of the array.

the demo on the site http://jolt-demo.appspot.com/ is

将Nifi中的列分成两列(数组)。

huangapple
  • 本文由 发表于 2023年6月6日 04:49:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76409910.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定