title: Merge JSON data with Python
body: <p>As part of a Python program, I want to merge JSON objects that contain identically structured data. For instance:</p>
  
  <pre><code>{
      "responseStatus": "SUCCESS",
      "responseDetails": {
          "total": 5754,
      },
      "data": [
          {
              "id": 1324651
          },
          {
              "id": 5686131
          }
      ]
  }
  </code></pre>
  
  <p>What I want to do is to add the content of the data array of my section object into the data array of my first object.</p>
  
  <p>So, assuming:</p>
  
  <pre><code>thejson1 = json.loads({"responseStatus": "SUCCESS","responseDetails": {"total": 5754,},"data": [{"id": 1324651},{"id": 5686131}]})
  thejson2 = json.loads({"responseStatus": "SUCCESS","responseDetails": {"total": 1234,},"data": [{"id": 2165735},{"id": 2133256}]})
  </code></pre>
  
  <p>I thought that executing:</p>
  
  <pre><code>thejson1["data"].append(thejson2["data"])
  </code></pre>
  
  <p>Would expand thejson1 into:</p>
  
  <pre><code>{
      "responseStatus": "SUCCESS",
      "responseDetails": {
          "total": 5754,
      },
      "data": [
          {
              "id": 1324651
          },
          {
              "id": 5686131
          },
          {
              "id": 2165735
          },
          {
              "id": 2133256
          }
      ]
  }
  </code></pre>
  
  <p>But what it does instead is add thejson2 data as an array within the data array of thejson1:</p>
  
  <pre><code>{
      "responseStatus": "SUCCESS",
      "responseDetails": {
          "total": 5754,
      },
      "data": [
          {
              "id": 1324651
          },
          {
              "id": 5686131
          },
          [
              {
                  "id": 2165735
              },
              {
                  "id": 2133256
              }
          ]
      ]
  }
  </code></pre>
  
  <p>So, what am I doing wrong? It looks like append adds the data array of the second JSON object instead of its content, but note that I can't know in advance the contents of the "data" array in my JSON input, so I can't write code that specifically loops in the "id" objects to add them one by one.</p>
  
  <p>Thanks in advance!</p>
  
  <p>R.</p>