title: Combine json files and preserve format in R
body: <p>I have two json files in the exact format as below.  My goal is to combine them and keep the exact same format  - just basically stack one on top of the other.</p>
  
  <p>I have tried the following but this does not correctly combine both files and preserve the format as both files are bracketed with <code>[ ]</code> separately.  How does one combine and keep only one pair of brackets around the entire file? </p>
  
  <pre><code>files &lt;- c("test.json","test2.json")
  jsonl &lt;- lapply(files, function(f) fromJSON(file = f))
  jsonc &lt;- toJSON(jsonl)
  write(jsonc, file = "two.json")
  </code></pre>
  
  <p>Are there any better solutions in R? </p>
  
  <p><code>test.json</code>:</p>
  
  <pre><code>[
    {
      "vendor": 0,
      "startTime": 4380,
      "endTime": 4445
    },
    {
      "vendor": 0,
      "startTime": 4448,
      "endTime": 4453
    },
    {
      "vendor": 0,
      "startTime": 4696,
      "endTime": 4880
    }
  ]
  </code></pre>
  
  <p>undesired output:</p>
  
  <pre><code>[
    [
      {"vendor":0,"startTime":4380,"endTime":4445},
      {"vendor":0,"startTime":4448,"endTime":4453},
      {"vendor":0,"startTime":4696,"endTime":4880}],
  
      [{"vendor":0,"startTime":4380,"endTime":4445},
        {"vendor":0,"startTime":4448,"endTime":4453},
        {"vendor":0,"startTime":4696,"endTime":4880}
    ]
  ]
  </code></pre>
  
  <p>desired output:</p>
  
  <pre><code>  [
      {"vendor":0,"startTime":4380,"endTime":4445},
      {"vendor":0,"startTime":4448,"endTime":4453},
      {"vendor":0,"startTime":4696,"endTime":4880},
      {"vendor":0,"startTime":4380,"endTime":4445},
      {"vendor":0,"startTime":4448,"endTime":4453},
      {"vendor":0,"startTime":4696,"endTime":4880}
    ]
  </code></pre>