Pushdown a top level field into each element of an array using JOLT
<p>I am working on to push down the top level field into each element of the array inside it.</p>

<ol>
<li>I want to push 'country' into the each element of 'state' array</li>
<li>I want to push 'stateName' into the each element of 'cities' array</li>
</ol>

<p>Input JSON : </p>

<pre><code>{
    "country": "usa",
    "state": [
        {
            "stateName": "TX",
            "location": "south",
            "cities": [
                {
                    "name": "Austin",
                    "pop": "1M"
                },
                {
                    "name": "Dallas",
                    "pop": "2M"
                }
            ]
        },
        {
            "stateName": "CA",
            "location": "west",
            "cities": [
                {
                    "name": "SanFran",
                    "pop": "3M"
                },
                {
                    "name": "LosAngeles",
                    "pop": "4M"
                }
            ]
        }
    ]
}
</code></pre>

<p>Expected Output JSON:</p>

<pre><code>{
    "state": [
        {
            "country": "usa",      // pushed down country field into state array
            "stateName": "TX",
            "location": "south",
            "cities": [
                {
                    "stateName": "TX",   // pushed down stateName field into cities array
                    "name": "Austin",
                    "pop": "1M"
                },
                {
                    "stateName": "TX",
                    "name": "Dallas",
                    "pop": "2M"
                }
            ]
        },
        {
            "country": "usa",
            "stateName": "CA",
            "location": "west",
            "cities": [
                {
                    "stateName": "CA",
                    "name": "SanFran",
                    "pop": "3M"
                },
                {
                    "stateName": "CA",
                    "name": "LosAngeles",
                    "pop": "4M"
                }
            ]
        }
    ]
}
</code></pre>