title: How to combine 2 json payload in mule 4 using dataweave
body: <p>From two different flows I am getting a json output payload and what to combine them based on a common key. The keys are dynamic, so I want to write a generic dataweave that will work for any key.</p>
  <p>Input-1:</p>
  <pre><code>[
    {
      &quot;CustomerID&quot;: &quot;123&quot;,
      &quot;Name&quot;: &quot;Maria&quot;,
      &quot;Phone&quot;: &quot;030-0074321&quot;
      
    },
    {
      &quot;CustomerID&quot;: &quot;56654&quot;,
      &quot;Name&quot;: &quot;sdf&quot;,
      &quot;Phone&quot;: &quot;030-6877452&quot;
      
    }
  ]
  </code></pre>
  <p>Input-2:</p>
  <pre><code>[
      {
        &quot;OrderID&quot;: &quot;10643&quot;,
        &quot;CustomerID&quot;: &quot;123&quot;,
        &quot;Price&quot;: &quot;200&quot;
      },
      {
        &quot;OrderID&quot;: &quot;10692&quot;,
        &quot;CustomerID&quot;: &quot;123&quot;,
        &quot;Price&quot;: &quot;566&quot;
      },
      {
        &quot;OrderID&quot;: &quot;10702&quot;,
        &quot;CustomerID&quot;: &quot;56654&quot;,
        &quot;Price&quot;: &quot;546&quot;
      }
    ]
  </code></pre>
  <p>Expected Output:</p>
  <pre><code>[
     {
        &quot;CustomerID&quot;:&quot;123&quot;,
        &quot;Name&quot;:&quot;Maria&quot;,
        &quot;Phone&quot;:&quot;030-0074321&quot;,
        &quot;Details&quot;:[
           {
              &quot;OrderID&quot;:&quot;10643&quot;,
              &quot;Price&quot;:&quot;200&quot;
           },
           {
              &quot;OrderID&quot;:&quot;10692&quot;,
              &quot;Price&quot;:&quot;566&quot;
           }
        ]
     },
     {
        &quot;CustomerID&quot;:&quot;56654&quot;,
        &quot;Name&quot;:&quot;sdf&quot;,
        &quot;Phone&quot;:&quot;030-6877452&quot;,
        &quot;Details&quot;:[
           {
              &quot;OrderID&quot;:&quot;10702&quot;,
              &quot;Price&quot;:&quot;546&quot;
           }
        ]
     }
  ]
  </code></pre>
  <p>Based on the common key(in this example CustomerID) I want to combine both the inputs.
  As I mentioned all the keys (CustomerID,Name,Phone,OrderID,Price) are not same all the time, they are dynamic.</p>
  <p>Can someone help me write a dynamic dataweave code?</p>
  <p>Thanks in advance</p>