Import JSON key containing a no-break space
<p>I have a long json file that is generated automatically that contains a no-break space in a JSON key (don't ask my why....). I didn't find a solution to properly import that key+value in R. The no-break space is in the key 'Rain in\u00a0mm\'</p>

<p>Here some reproducible data:</p>

<pre><code>#library(jsonlite)
library(rjson)
library (plyr)    
test_data &lt;- fromJSON("[{\"_id\":\"QuWQsXzuqiiAgYM9b\",\"cronjobname\":\"Precip_test\",\"cronjobid\":\"wLbS9XwREnvaChoyu\",\"cronjobtyp\":\"importTestData\",\"datasource\":\"importTestData\",\"data\":[{\"City\":\"New York\",\"Type\":\"Precip\",\"Time\":\"30.04.2016 11:30\",\"Rain in\\u00a0mm\":0}],\"createdAt\":\"2016-05-01T12:10:01.001Z\",\"createdBy\":null,\"modifiedAt\":\"2016-05-01T12:10:01.001Z\",\"modifiedBy\":null}]")
</code></pre>

<p>I tried replacing all kinds of whitespace with <code>gsub("[[:space:]]", " ", names(x))</code> and then let <code>make.names</code> automatically generate key names. However, I still can't get the "Rain in mm" key to show up in my dataframe. No matter what I do, only City and Time show up. Any hints on what I'm missing?</p>

<pre><code>test &lt;- lapply(test_data[[1]]$data, function(x) {
  x[sapply(x, is.null)] &lt;- NA
  gsub("[[:space:]]", " ", names(x))
  make.names(names(x))
  c(x$City, x$Rain.in.mm, x$Time)
})
test &lt;- ldply (test)
str(test)
</code></pre>

<p>Here also the code to see what <code>gsub</code> and <code>make.names</code> do:</p>

<pre><code>make.names(names(test_data[[1]]$data[[1]]))
gsub("[[:space:]]", " ", names(test_data[[1]]$data[[1]]))
</code></pre>