title: How to bring the elements under different nodes onto one common node in JSON using JavaScript?
body: <p>Here is sample JSON data. It has one 'PO' and inside 'PO' there are multiple 'SO' nodes. Inside an 'SO' node there can be multiple nodes each containing one 'B', 'R', 'F'.</p>
  <pre><code>{
      &quot;PO&quot;: [
          {
              &quot;SO&quot;: [
                  {
                      &quot;B&quot;: &quot;XXX&quot;,
                      &quot;R&quot;: &quot;YYY&quot;,
                      &quot;F&quot;: &quot;ZZZ&quot;
                  },
                  {
                      &quot;B&quot;: &quot;MMM&quot;,
                      &quot;R&quot;: &quot;NNN&quot;,
                      &quot;F&quot;: &quot;PPP&quot;
                  }
              ],
              &quot;SO&quot;: [
                  {
                      &quot;B&quot;: &quot;111&quot;,
                      &quot;R&quot;: &quot;222&quot;,
                      &quot;F&quot;: &quot;333&quot;
                  },
                  {
                      &quot;B&quot;: &quot;333&quot;,
                      &quot;R&quot;: &quot;444&quot;,
                      &quot;F&quot;: &quot;555&quot;
                  },
                  {
                      &quot;B&quot;: &quot;666&quot;,
                      &quot;R&quot;: &quot;777&quot;,
                      &quot;F&quot;: &quot;888&quot;
                  }
              ]
          }
      ]
  }
  </code></pre>
  <p>I want this data to be like this</p>
  <pre><code>{
      &quot;PO&quot;: [
          {
              &quot;B&quot;: &quot;XXX&quot;,
              &quot;R&quot;: &quot;YYY&quot;,
              &quot;F&quot;: &quot;ZZZ&quot;
          },
          {
              &quot;B&quot;: &quot;MMM&quot;,
              &quot;R&quot;: &quot;NNN&quot;,
              &quot;F&quot;: &quot;PPP&quot;
          },
          {
              &quot;B&quot;: &quot;111&quot;,
              &quot;R&quot;: &quot;222&quot;,
              &quot;F&quot;: &quot;333&quot;
          },
          {
              &quot;B&quot;: &quot;333&quot;,
              &quot;R&quot;: &quot;444&quot;,
              &quot;F&quot;: &quot;555&quot;
          },
          {
              &quot;B&quot;: &quot;666&quot;,
              &quot;R&quot;: &quot;777&quot;,
              &quot;F&quot;: &quot;888&quot;
          }
      ]
  }
  </code></pre>
  <p>How can I do this in Javascript?</p>
  <p>I tried <code>obj.PO[0].SO</code> where obj is the JSON object and some replace functions to replace the 'SO' nodes, but couldn't get it to work.</p>