title: Converting R list to JSON
body: <p>A simple question - I'd like to convert a list to JSON in R.
  Let's say this is my list:</p>
  
  <pre><code>listtest = list(
    list(section_id = NULL, name = 'name1', slug = 'slug1'),
    list(section_id = NULL, name = 'name2', slug = 'slug2'),
    list(section_id = NULL, name = 'name3', slug = 'slug3', categories = 
           list(
             list(section_id = NULL, name = 'name31', slug = 'slug31'),
             list(section_id = NULL, name = 'name32', slug = 'slug32')
           )
    )
  )
  </code></pre>
  
  <p>So I use a simple </p>
  
  <pre><code>jsontest = toJSON(listtest, pretty = TRUE, auto_unbox = TRUE)
  </code></pre>
  
  <p>Then I get a JSON like this:</p>
  
  <pre><code>[
    {
      "section_id": {},
      "name": "name1",
      "slug": "slug1"
    },
    {
      "section_id": {},
      "name": "name2",
      "slug": "slug2"
    },
    {
      "section_id": {},
      "name": "name3",
      "slug": "slug3",
      "categories": [
        {
          "section_id": {},
          "name": "name31",
          "slug": "slug31"
        },
        {
          "section_id": {},
          "name": "name32",
          "slug": "slug32"
        }
      ]
    }
  ] 
  </code></pre>
  
  <p>However, at the beginning and end of the code I get '[' and ']'. How can I get rid of this? When uploading to mongoDB it gives me an error whereas without the brackets it works fine.</p>