Json JOLT转换-将新元素命名为数组元素的值
我不确定这是否可能与颠簸转换。但我想将随机顺序的json更改为具体名称: 输入json:Json JOLT转换-将新元素命名为数组元素的值,json,jolt,Json,Jolt,我不确定这是否可能与颠簸转换。但我想将随机顺序的json更改为具体名称: 输入json: { "scheduler" : { "schedulerInfo" : { "usedCapacity" : 50.0, "queueName" : "root", "queues" : { "queue"
{
"scheduler" : {
"schedulerInfo" : {
"usedCapacity" : 50.0,
"queueName" : "root",
"queues" : {
"queue" : [ {
"type" : "capacitySchedulerLeafQueueInfo",
"usedCapacity" : 10.0,
"queueName" : "jupyter"
}, {
"type" : "capacitySchedulerLeafQueueInfo",
"usedCapacity" : 25.0,
"queueName" : "spark"
},
{
"type" : "capacitySchedulerLeafQueueInfo",
"usedCapacity" : 15.0,
"queueName" : "dremio"
}
} ]
}
}
}
}
预期结果:
{
"rootUsedCapacity": 50.0,
"jupyterUsedCapacity": 10.0,
"sparkUsedCapacity": 25.0,
"dremioUsedCapacity":15.0
}
我知道如何使其保持静态,但我不知道如何将“queueName”的值添加到新属性&value+UsedCapacity:&ArrayValue
静态解决方案:
[
{
"operation": "shift",
"spec": {
"scheduler": {
"schedulerInfo": {
"usedCapacity": "rootUsedCapacity",
"queues": {
"queue": {
"0": {
"usedCapacity": "jupyterUsedCapacity"
},
"1": {
"usedCapacity": "sparkUsedCapacity"
},
"2": {
"usedCapacity": "dremioUsedCapacity"
}
}
}
}
}
}
}
]
使用UsedCapacity字符串连接queueName,然后使用UsedCapacity移动新创建的节点
[
{
"operation": "modify-default-beta",
"spec": {
"scheduler": {
"schedulerInfo": {
"queues": {
"queue": {
"*": {
"queueNameNew": "=concat(@(1,queueName),'UsedCapacity')"
}
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"scheduler": {
"schedulerInfo": {
"usedCapacity": "rootUsedCapacity",
"queues": {
"queue": {
"*": {
"usedCapacity": "@(1,queueNameNew)"
}
}
}
}
}
}
}
]