无法使用 JOLT 转换将一组字段从数组转换为各自的单独数组
Unable to convert group of fields from an array into respective individual arrays using JOLT transformation
输入:
{
"chain": [
{
"formation": [
{
"itemID": "1111",
"isConsiderable": false
},
{
"itemID": "2222",
"isConsiderable": false
}
]
},
{
"formation": [
{
"itemID": "3333",
"isConsiderable": false
},
{
"itemID": "4444",
"isConsiderable": false
}
]
}
]
}
颠簸规格:
[
{
"operation": "shift",
"spec": {
"chain": {
"*": {
"formation": {
"*": {
"itemID": "productsList[&1].products"
}
}
}
}
}
}
]
当前输出:
{
"productsList" : [ {
"products" : [ "1111", "3333" ]
}, {
"products" : [ "2222", "4444" ]
} ]
}
期望的输出:
{
"productsList" : [ {
"products" : [ "1111", "2222" ]
}, {
"products" : [ "3333", "4444" ]
} ]
}
我想匹配每个队形数组的 itemID 并将它们分组到相应的数组中。
通过使用 jolt 转换,我能够对产品数组进行分组,但不能按照所需的格式进行分组,并且想要对各个数组的 itemID 进行分组,但这里对发生在输入中所有数组的相同索引上的字段进行分组 json.
提前致谢
在您的规范中,&1
指的是存储在 formation
键下的数组中的索引。您需要在链数组 (&3
) 中指定索引,然后在 formation
数组中指定索引 - 如以下规范所示:
[
{
"operation": "shift",
"spec": {
"chain": {
"*": {
"formation": {
"*": {
"itemID": "productsList[&3].products[&1]"
}
}
}
}
}
}
]
输入:
{
"chain": [
{
"formation": [
{
"itemID": "1111",
"isConsiderable": false
},
{
"itemID": "2222",
"isConsiderable": false
}
]
},
{
"formation": [
{
"itemID": "3333",
"isConsiderable": false
},
{
"itemID": "4444",
"isConsiderable": false
}
]
}
]
}
颠簸规格:
[
{
"operation": "shift",
"spec": {
"chain": {
"*": {
"formation": {
"*": {
"itemID": "productsList[&1].products"
}
}
}
}
}
}
]
当前输出:
{
"productsList" : [ {
"products" : [ "1111", "3333" ]
}, {
"products" : [ "2222", "4444" ]
} ]
}
期望的输出:
{
"productsList" : [ {
"products" : [ "1111", "2222" ]
}, {
"products" : [ "3333", "4444" ]
} ]
}
我想匹配每个队形数组的 itemID 并将它们分组到相应的数组中。 通过使用 jolt 转换,我能够对产品数组进行分组,但不能按照所需的格式进行分组,并且想要对各个数组的 itemID 进行分组,但这里对发生在输入中所有数组的相同索引上的字段进行分组 json.
提前致谢
在您的规范中,&1
指的是存储在 formation
键下的数组中的索引。您需要在链数组 (&3
) 中指定索引,然后在 formation
数组中指定索引 - 如以下规范所示:
[
{
"operation": "shift",
"spec": {
"chain": {
"*": {
"formation": {
"*": {
"itemID": "productsList[&3].products[&1]"
}
}
}
}
}
}
]