我试图为下面的输入颠簸转换规范:
{
"a": {
"serviceTesta": "Testa1",
"b": {
"serviceTestb": "Testb1",
"c": [
{
"name": "x",
"value": "100",
"desc": "this is description of X"
},
{
"name": "y",
"value": "200",
"desc": "this is description of y"
}
]
}
}
}
预期产量如下:
[
{
"Testa1_Testb1_x": "100",
"Testa1_Testb1_x_desc": "this is description of X"
},
{
"Testa1_Testb1_y": "100",
"Testa1_Testb1_y_desc": "this is description of y"
}
]
我的规格:
[
{
"operation": "shift",
"spec": {
"a": {
"b": {
"c": {
"*": {
"value": "@(4,serviceTesta).@(3,serviceTestb)@(1,name)"
}
}
}
}
}
}
]
我是jolt的新手,尝试过不同的方式,但无法获得所需的输出。任何帮助都非常感谢。
谢谢
您可以通过对转换进行二次转换来实现所需的结果:
它使用*
和&n
的组合来建立你的钥匙。
[
{
"operation": "shift",
"spec": {
"a": {
"b": {
"c": {
"*": {
"value": "@(4,serviceTesta).@(3,serviceTestb).@(1,name)"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": {
"@": "&3_&2_&1"
}
}
}
}
}
]