title: Manipulation of JSON string in R before conversion to data.frame
body: <p>I have a url which updates periodically with some JSON data which I would like to convert to a datatable in R with the following code</p>
  
  <pre><code>library(jsonlite)
  fromJSON("http://...")
  </code></pre>
  
  <p>however this is not working and I think it is due to the way the JSON is structured. To my understanding the file is currently structured as following.</p>
  
  <pre><code>{"h1":[{"h2":[{"Name":"Column1Header","Value":"Row1Column1Value"},{"Name":"Column2Header","Value":"Row1Column2Value"}]},{"h2":[{"Name":"Column1Header","Value":"Row2Column1Value"},{"Name":"Column2Header","Value":"Row2Column2Value"}]}]}
  </code></pre>
  
  <p>I think if I could read in the url as a long string and manipulate it to something like what is below and call the function </p>
  
  <pre><code>fromJSON()
  </code></pre>
  
  <p>I will be able to obtain the data.table I want. </p>
  
  <pre><code>[{"Column1Header":"Row1Column1Value","Column2Header":"Row1Column2Value"},{"Column1Header":"Row2Column1Value","Column2Header":"Row2Column2Value"}]
  </code></pre>
  
  <p>Any idea how I can achieve this? My attempt to solve this involved using the <code>readLines()</code> function and using <code>gsub()</code> to replace the bits I don't need. However,  <code>readLines</code> is placing "\" all through the data which I am having all sorts of trouble removing and even if I get past that my <code>gsub</code> approach wouldn't be very robust. </p>
  
  <p>Any help would be much appreciated as reading the file as it is now isn't letting me get into the level of detail I require to extract the "Name,Value" pairs which I require to build my <code>data.table</code>.</p>
  
  <p>p.s. Something tells me that for some reason the original JSON file is transposed as the column names don't necessarily comply with the export systems naming convention.</p>