title: Getting data from JSON file in R
body: <p>Lets say that I have the following json file:</p>
  
  <pre><code>{
    "id": "000018ac-04ef-4270-81e6-9e3cb8274d31",
     "currentCompany": "",
     "currentTitle": "--",
     "currentPosition": ""
  }
  </code></pre>
  
  <p>I use the following code:</p>
  
  <pre><code>Usersfile &lt;- ('trial.json') #where trial the json above
  library('rjson')
  c &lt;- file(Usersfile,'r')
  l &lt;- readLines(c,-71L)
  json &lt;- lapply(X=l,fromJSON)
  </code></pre>
  
  <p>and I have the following error:</p>
  
  <pre><code>Error: parse error: premature EOF
                                     {
                   (right here) ------^
  </code></pre>
  
  <p>But when I enter the json file(with notepad) and put the data in one line:</p>
  
  <pre><code>{"id": "000018ac-04ef-4270-81e6-9e3cb8274d31","currentCompany": "","currentTitle": "--","currentPosition": ""}
  </code></pre>
  
  <p>The code works fine.(In reality the file is really big to do it manually for each line). Why is this happening? How can I overcome that?</p>
  
  <p>Also this one doesnt work:</p>
  
  <pre><code>{ "id": "000018ac-04ef-4270-81e6-9e3cb8274d31","currentCompany": "","currentTitle": "--","currentPosition": ""
  }
  </code></pre>
  
  <p><strong>EDIT</strong>: I used the following code that I could read only the first value:</p>
  
  <pre><code>library('rjson')
  c &lt;- file.path(Usersfile)
  data &lt;- fromJSON(file=c)
  </code></pre>