I'm trying to construct an array of objects named catalogs with different combinations of input values, but can't set some attributes in the same object. This is the current progress:
[
{
"operation": "shift",
"spec": {
"new": {
"bc_sku_channel": {
"*": {
"Partner": null, //ignore if value is Partner
"*": {
"#BC": "catalogs[#3].catalog",
"@1": "catalogs[#3].channel"
}
}
},
"bc_sku_partner": {
"*": {
"#BC": "catalogs[].catalog", // don't know which index should be here to group these 3 attributes into the same object
"#Partner": "catalogs[].channel", // tried #3,#2,#1,#4 but doesn't work
"@": "catalogs[].partner"
}
},
"cc_sku_channel": {
"*": {
"Partner": null, //ignore if value is Partner
"*": {
"#CC": "catalogs[#3].catalog",
"@1": "catalogs[#3].channel"
}
}
}
}
}
}
]
Input:
{
"new": {
"bc_sku_partner": [
"Amazon",
"Ebay"
],
"bc_sku_channel": [
"Partner",
"Online",
"Store"
],
"cc_sku_channel": [
"Store"
]
}
}
Expected Output:
{
"catalogs": [
{
"catalog": "BC",
"channel": "Partner",
"partner": "Amazon"
},
{
"catalog": "BC",
"channel": "Partner",
"partner": "Ebay"
},
{
"catalog": "BC",
"channel": "Online"
},
{
"catalog": "BC",
"channel": "Store"
},
{
"catalog": "CC",
"channel": "Store"
}
]
}
Now I have only been able to build the last 3 objects.
Notes:
If channel is Online or Store the object shouldn't have the partner attribute.
For each partner, the channel attribute should be always Partner