英文:
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/上的演示如下:
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论