Copy attrs from element to all elements of array

How to copy all atrs of “hardcode_elements” to all objects of “final_object”

"hardcoded_elements":{
    "uom":"PCS",
    "brand":"Some Brand"
},
"final_object":{
    [
        {
            "key":"12345678",
            "name":"QWERTY"        
        },
        {
            "key":"9876543",
            "name":"ASDFGH"        
        }
    ]
}

to have

"hardcoded_elements":{
    "uom":"PCS",
    "brand":"Some Brand"
},
"final_object":{
    [
        {
            "key":"12345678",
            "name":"QWERTY" ,
            "uom":"PCS",
            "brand":"Some Brand"       
        },
        {
            "key":"9876543",
            "name":"ASDFGH",
            "uom":"PCS",
            "brand":"Some Brand"        
        }
    ]
}

I have it.
At first use Recursively copy values to children

and then
in Node, transform nodes
use
Copy using a pattern

Hi @vosy

We are glad to hear that you manage to resolve the problem.

You are correct that “Recursively copy values to children” is the right transformer to copy values to all objects in an array. With only the transformer, you can already achieve your goal with the following configuration.

Please give it a try and let us know if you have any further questions.

Hi, thank you very much!, i’v already got solution.
Ur solution is hardcoded, it is not good.
But, thank u :slight_smile:

Hi @vosy,

Glad you found a solution! :slight_smile:

My example was just a quick hardcoded sample to demonstrate the idea, but you can actually configure the transformers according to your requirements :wink:

1 Like