vosy
June 13, 2025, 1:51pm
1
Hi how can i get all variant of all products.variants into one root array all_variants
{
"products":{
"produkt_some_code_abc":{
"variants":{
"variant":{
"code":"artrertwetrwe"
},
"variant":{
"code":"asdgsdgfdsg"
}
}
},
"produkt_some_code_dfs":{
"variants":{
"variant":{
"code":"sdgsdfgdg"
},
"variant":{
"code":"sdgsdgfsdgf"
}
}
}
"produkt_some_code_gfr":{
"variants":{
"variant":{
"code":"dgsdfgsdg"
},
"variant":{
"code":"gdfgsdfgsdg"
}
}
}
}
}
to
{
"all_variants":{
"show_item":{
"code":"artrertwetrwe"
},
"show_item":{
"code":"asdgsdgfdsg"
},
"show_item":{
"code":"sdgsdfgdg"
},
"show_item":{
"code":"sdgsdgfsdgf"
},
"show_item":{
"code":"dgsdfgsdg"
},
"show_item":{
"code":"gdfgsdfgsdg"
}
}
}
vosy
June 16, 2025, 5:55am
2
Hi,
adjustment of input data
{
"products":{
"produkt_some_code_abc":{
"variants":{
"variant":[
{
"code":"artrertwetrwe",
"some_data":"sasdfasf"
},
{
"code":"asdgsdgfdsg",
"some_data":"asdfasdf"
}
]
}
},
"produkt_some_code_dfs":{
"variants":{
"variant":[
{
"code":"sdgsdfgdg",
"some_data":"fghjfghj"
},
{
"code":"sdgsdgfsdgf",
"some_data":"werqerqwr"
}
]
}
}
"produkt_some_code_gfr":{
"variants":{
"variant":[
{
"code":"dgsdfgsdg",
"some_data":"vxncvbncv"
},
{
"code":"gdfgsdfgsdg",
"some_data":"sasdf nyjntjy asf"
}
]
}
}
}
}
to
{
"all_variants":{
"shop_item":{
"code":"artrertwetrwe",
"some_data":"sasdfasf"
},
"shop_item":{
"code":"asdgsdgfdsg",
"some_data":"asdfasdf"
},
"shop_item":{
"code":"sdgsdfgdg",
"some_data":"fghjfghj"
},
"shop_item":{
"code":"sdgsdgfsdgf",
"some_data":"werqerqwr"
},
"shop_item":{
"code":"dgsdfgsdg",
"some_data":"vxncvbncv"
},
"shop_item":{
"code":"gdfgsdfgsdg",
"some_data":"sasdf nyjntjy asf"
}
}
}
Hi @vosy ,
I see that you managed to get the expected result? Can you please confirm it? or you still need some other adjustments?
vosy
June 16, 2025, 8:12am
5
Hi My friend :),
no i didnt get expected result, I only adjusted input data here.
{
"products":{
"produkt_some_code_abc":{
"variants":{
"variant":[
{
"code":"artrertwetrwe",
"some_data":"sasdfasf"
},
{
"code":"asdgsdgfdsg",
"some_data":"asdfasdf"
}
]
}
},
"produkt_some_code_dfs":{
"variants":{
"variant":[
{
"code":"sdgsdfgdg",
"some_data":"fghjfghj"
},
{
"code":"sdgsdgfsdgf",
"some_data":"werqerqwr"
}
]
}
}
"produkt_some_code_gfr":{
"variants":{
"variant":[
{
"code":"dgsdfgsdg",
"some_data":"vxncvbncv"
},
{
"code":"gdfgsdfgsdg",
"some_data":"sasdf nyjntjy asf"
}
]
}
}
}
}
Im trying to use “Copy using a pattern” transformet, but im not able to get final result
{
"all_variants":{
"shop_item":{
"code":"artrertwetrwe",
"some_data":"sasdfasf"
},
"shop_item":{
"code":"asdgsdgfdsg",
"some_data":"asdfasdf"
},
"shop_item":{
"code":"sdgsdfgdg",
"some_data":"fghjfghj"
},
"shop_item":{
"code":"sdgsdgfsdgf",
"some_data":"werqerqwr"
},
"shop_item":{
"code":"dgsdfgsdg",
"some_data":"vxncvbncv"
},
"shop_item":{
"code":"gdfgsdfgsdg",
"some_data":"sasdf nyjntjy asf"
}
}
}
and finally id like to have xml
<shop>
<shopitem>
<code/>
<some_data/>
</shopitem>
<shopitem>
<code/>
<some_data/>
</shopitem>
<shopitem>
<code/>
<some_data/>
</shopitem>
<shopitem>
<code/>
<some_data/>
</shopitem>
</shop>
Hi @vosy ,
The expected result that you mentioned on the JSON format is not possible because that’s not a valid JSON data. You have a duplicate “shop_item” key on your “all_variants” object. However, your final result (in XML) is possible.
First step is to convert it into list of array instead of an object, see below :
{
"allVariants": {
"shop_item": [
{
"code": "artrertwetrwe",
"some_data": "sasdfasf"
},
{
"code": "asdgsdgfdsg",
"some_data": "asdfasdf"
},
{
"code": "sdgsdfgdg",
"some_data": "fghjfghj"
},
{
"code": "sdgsdgfsdgf",
"some_data": "werqerqwr"
},
{
"code": "dgsdfgsdg",
"some_data": "vxncvbncv"
},
{
"code": "gdfgsdfgsdg",
"some_data": "sasdf nyjntjy asf"
}
]
}
}
To achieve that, you can use “Copy using a pattern” transformer, from products.*.variants.variant.*
to allVariants.shop_item.$1$2
, see below :
Then, use “value mapper” to convert it into array :
Final step, to convert it into XML, you can use “Serialize” transformer, see below :
Then you have your XML document as a result. Could you please give it a try?
vosy
June 16, 2025, 9:08am
8
so, u r the best.
point was use “List: Get values” in mapper.
thank you very much! i know next feature
Thank u a lot
1 Like