title: Why is there a lexical error: invalid char in json text when json_string is sent over curl, but not in R console?
body: <p>I used Plumber (<a href="https://github.com/trestletech/plumber" rel="nofollow noreferrer">https://github.com/trestletech/plumber</a>) to create a web API for a R source code, which purpose is to process a json_string as an input, and converting it into a R dataframe.</p>
  
  <p>R code:  </p>
  
  <pre><code>#* @param data
  #* @post /predict
  jsonToDF &lt;- function(data) {
      library(jsonlite)
      dat &lt;- fromJSON(data)
  }
  </code></pre>
  
  <p>As you can see from the code above, I'm using the library <code>jsonlite</code> and the <code>fromJSON()</code> method. </p>
  
  <p>Then I exposed the service locally via:</p>
  
  <pre><code>library(plumber) 
  r &lt;- plumb("code.R")
  r$run(port=54321)
  </code></pre>
  
  <p>I used the curl request:</p>
  
  <pre><code>curl -v -i -X POST -H "Content-Type: application/json" --data "testData='{\"a\":\"b\"}'" http://localhost:54321/predict 
  </code></pre>
  
  <p>to send a json_string (<code>{"a":"b"}</code>) but this is the error i got:</p>
  
  <pre><code>&lt;simpleError: lexical error: invalid char in json text.
                                         '{"a":"b"}'
                       (right here) ------^
  </code></pre>
  
  <p>I used R console to double check the validity of the input, and i did not get the same error message.</p>
  
  <pre><code>&gt; z &lt;- fromJSON('{"a":"b"}')
  &gt; z
  $a
  [1] "b"
  </code></pre>
  
  <p>Can anyone explain to me why it works in R console, but not as an input in the data field of the curl requests? Thank you very much!</p>