title: Convert JSON to DF in R
body: <p>I have a large data file filled up of key value pairs. The key is an ID and the value is a huge json object. I have been trying to convert this data file to a df in R, by importing the data as a 2 column table and then converting the value to a data frame.</p>
  <p>I keep getting this error, even after I validated my json.</p>
  <blockquote>
  <p>Error: lexical error: invalid string in json text.</p>
  <pre><code>                                [{ f: { SEQNUM: [ 455043, 455044, 
                   (right here) ------^
  </code></pre>
  </blockquote>
  <p>below is my code</p>
  <pre><code>part00013 &lt;- read.table(PatientData, sep = '\t', header = F, as.is = T)
  colnames(part00013) &lt;- c('k','v')
  make_indexDateLists &lt;- function(x) {
  #  x['v'] &lt;- lapply(x['v'], function(y) as.character(y))
  #  x['v'] &lt;- lapply(x['v'], function(y) substr(y,1, nchar(y)-1 ))
  #  x['v'] &lt;- lapply(x['v'], function(y) substr(y,2,nchar(y)))              
    x[&quot;v&quot;] &lt;- lapply(as.character(x[&quot;v&quot;]), function(y) jsonlite::fromJSON(y,simplifyVector = T))
    
    #do assignpatienttocohorts
    
    x[&quot;v&quot;] &lt;- lapply(x[&quot;v&quot;], function(y) RJSONIO::toJSON(y))
    
    cbind(x$k, x$v)
  }
  
  make_indexDateLists(part00013)
  </code></pre>
  <p>and here is a sample file <a href="https://drive.google.com/open?id=0B6hKduYaYwdJQ3BwbUpNSW9EZk0" rel="nofollow noreferrer">https://drive.google.com/open?id=0B6hKduYaYwdJQ3BwbUpNSW9EZk0</a></p>