Adding subkey-value pairs to existing array (or JSON object?) in javascript
<p>Been wracking my brain and googling like mad, but perhaps I'm not searching with the right keywords.</p>

<p>Got a list/array/JSON serialized data (doesn't really matter at this point) like so:</p>

<pre><code>{ 
  "program": 1,
  "program": 2,
  "program": 3
}
</code></pre>

<p>and I'm receiving a series of JSON objects over a node-based socket.io that looks something like this:</p>

<pre><code>{ "program": 1, "sequence_number": 1 }
{ "program": 3, "sequence_number": 2 }
{ "program": 3, "sequence_number": 1 }
{ "program": 2, "sequence_number": 2 }
{ "program": 2, "sequence_number": 1 }
{ "program": 2, "sequence_number": 3 }
</code></pre>

<p>And what I am having trouble figuring out is to be able to push/inject/merge this incoming JSON (one at a time as they are received) into my list above to create the following:</p>

<pre><code>{ 
  "program": 1,
    { 
      "sequence_number": 1
    },
  "program": 2,
    {  
      "sequence_number": 2,
      "sequence_number": 1,
      "sequence_number": 3
    },
  "program": 3,
    {
      "sequence_number": 2,
      "sequence_number": 1
    }
}
</code></pre>

<p>It's one of those things that is akin to being "on the tip of the tongue" but have reached a wall.  So I appeal to the community for some tidbits of wisdom, favored solutions, or pointing in the right direction with any known related tutorials.  Thanks in advance!</p>

<h1>Update 08.Oct.2016</h1>

<p>To address comments regarding the bad format of my list, how about a restructuring of the data, like so:</p>

<pre><code>{
  "program": 1,
  "sequence_list": 
  [
    { "sequence_number": 1 },
    { "sequence_number": 2 }
  ]
},
{
  "program": 2,
  "sequence_list": 
  [
    { "sequence_number": 1 },
    { "sequence_number": 3 },
    { "sequence_number": 2 }
  ]
}
... etc.
</code></pre>

<p>Does that make more sense?</p>