我正在尝试使用nifi jolttransformjson JSON来转换我的JSON。我正在使用这个网站的http://jolt-demo.appspot.com/#modify-stringFunctions
我有一个JSON
{
"response": {
"Attribute": [
{
"id": "670868",
"another_id": "8385",
"category": "A",
"type": "abc"
},
{
"id": "670870",
"another_id": "8385",
"category": "B",
"type": "abc"
}
]
}
}
我的Jolt Spec
enter code here
[
{
"operation": "shift",
"spec": {
"response": {
"Attribute": {
"*": {
"type": "TYPE",
"category": "CATEGORY"
}
}
}
}
}
]
当前输出为
{
"TYPE" : [ "abc", "abc" ],
"CATEGORY" : [ "A", "B" ]
}
想要的输出是
[
{
"TYPE":"abc",
"CATEGORY":"A"
},
{
"TYPE":"abc",
"CATEGORY":"B"
}
]
请帮帮忙。我尝试了这么多组合,但我似乎想不通。
发布于 2019-02-22 09:15:59
参见Map to List
示例,您将找到解决方案:
[
{
"operation": "shift",
"spec": {
"response": {
"Attribute": {
"*": {
"@type": "[#2].TYPE",
"@category": "[#2].CATEGORY"
}
}
}
}
}
]
https://stackoverflow.com/questions/54818571
复制相似问题