# Go through node transformer and insert value from root attributes

**URL:** <https://forum.alumio.com/t/go-through-node-transformer-and-insert-value-from-root-attributes/2027>\
**Category:** General\
**Created:** [June 2, 2025, 1:33pm UTC](https://forum.alumio.com/t/go-through-node-transformer-and-insert-value-from-root-attributes/2027 "2025-06-02T13:33:07Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Gugi](https://forum.alumio.com/user_avatar/forum.alumio.com/gugi/32/236_2.png) [@Gugi](https://forum.alumio.com/u/Gugi)\
**Post date:** [June 4, 2025, 8:39am UTC](https://forum.alumio.com/t/go-through-node-transformer-and-insert-value-from-root-attributes/2027/6 "2025-06-04T08:39:52Z")

</div>

Hi @vosy,

It is very possible. Please find the steps you should do to achieve the objective.

For example, here is the original JSON:

```JSON
{
    "variants": {
        "variant": [
            {
                "by-lang": {
                    "data": [
                        {
                            "name": "A-board A1 Complete Set Bread English",
                            "@lang": "eu",
                            "description": "Complete A-Board with print design ..."
                        },
                        {
                            "name": "A-board A1 Complete Set Bread English",
                            "@lang": "es"
                        },
                        {
                            "name": "A-board A1 Complete Set Bread English",
                            "@lang": "cz",
                            "description": "CZ Complete A-Board with print design ..."
                        }
                    ]
                }
            },
            {
                "by-lang": {
                    "data": [
                        {
                            "head": {
                                "title": "A-board A1 stojan s tiskem pla ...",
                                "keywords": "A-board A1 Complete Set Coffee",
                                "description": "head description"
                            },
                            "name": "A-board A1 Complete Set Bread English",
                            "@lang": "pt"
                        },
                        {
                            "name": "A-board A1 Complete Set Bread English",
                            "@lang": "cz"
                        }
                    ]
                }
            }
        ]
    },
    "common-data": {
        "by-lang": {
            "data": [
                {
                    "@lang": "cz",
                    "description": ""
                },
                {
                    "@lang": "es",
                    "description": "es default desc"
                }
            ]
        }
    }
}

```

First, we should copy the `common-data.by-lang.data` array to each variant data using [Recursively copy values to children](https://forum.alumio.com/t/recursively-copy-values-to-children/287). This will allow each variant data to access common data since a deeper object in an array can’t access values from the higher level directly. The common data will be available as `default_lang`.

 ![image](https://alumio-forum.s3.dualstack.eu-central-1.amazonaws.com/uploads/original/2X/e/e170f395373e711eeade2ec679b635380cd96fb5.png)

Then, we should loop through the variant data using [Execute entity transformers](https://forum.alumio.com/t/how-to-use-execute-entity-transformers/993) and **Node, transform nodes**. This allows us to put transformers that will apply to each object separately in the array.

 ![image](https://alumio-forum.s3.dualstack.eu-central-1.amazonaws.com/uploads/original/2X/6/694dd0ca2ffd8df7af21cab86e6b564df0dfbf84.png)

Inside the **Node, transform nodes** , put another [Recursively copy values to children](https://forum.alumio.com/t/recursively-copy-values-to-children/287) to copy the `@lang` to each lang in the common data array for filtering purposes later. The selected lang will be available as `use_lang` on each common lang.

 ![image](https://alumio-forum.s3.dualstack.eu-central-1.amazonaws.com/uploads/original/2X/9/9f094929d11168fbf0edad846c4a41d2ae32e65e.png)

Still inside the same **Node, transform nodes** , put a [Value Setter](https://forum.alumio.com/t/how-to-use-value-setter/291) to set the `use_description` property using JMESPath.

```auto
&{description || (default_lang[?"@lang" == use_lang].description | [0]) || head.description || 'Description does not exist'}

```

 ![image](https://alumio-forum.s3.dualstack.eu-central-1.amazonaws.com/uploads/original/2X/8/8af01a5a27e1ab0adda51deda89a6f62b0ae6ef9.png)

Finally, you can remove the temporary `default_lang` property from each variant data using [Key Filter](https://forum.alumio.com/t/key-filter-transformer/1422).

 ![image](https://alumio-forum.s3.dualstack.eu-central-1.amazonaws.com/uploads/original/2X/d/de18ec19d9dbfcdf8c7031c0f5e6977c5dc26707.png)

Below is the result of the transformations.

```JSON
{
  "variants": {
    "variant": [
      {
        "by-lang": {
          "data": [
            {
              "name": "A-board A1 Complete Set Bread English",
              "@lang": "eu",
              "description": "Complete A-Board with print design ...",
              "use_description": "Complete A-Board with print design ..."
            },
            {
              "name": "A-board A1 Complete Set Bread English",
              "@lang": "es",
              "use_description": "es default desc"
            },
            {
              "name": "A-board A1 Complete Set Bread English",
              "@lang": "cz",
              "description": "CZ Complete A-Board with print design ...",
              "use_description": "CZ Complete A-Board with print design ..."
            }
          ]
        }
      },
      {
        "by-lang": {
          "data": [
            {
              "head": {
                "title": "A-board A1 stojan s tiskem pla ...",
                "keywords": "A-board A1 Complete Set Coffee",
                "description": "head description"
              },
              "name": "A-board A1 Complete Set Bread English",
              "@lang": "pt",
              "use_description": "head description"
            },
            {
              "name": "A-board A1 Complete Set Bread English",
              "@lang": "cz",
              "use_description": "Description does not exist"
            }
          ]
        }
      }
    ]
  },
  "common-data": {
    "by-lang": {
      "data": [
        {
          "@lang": "cz",
          "description": ""
        },
        {
          "@lang": "es",
          "description": "es default desc"
        }
      ]
    }
  }
}

```

We hope our explanation is clear to you. Feel free to let us know if you find any issues.

---

_[View the full topic](https://forum.alumio.com/t/go-through-node-transformer-and-insert-value-from-root-attributes/2027)._
