'Error in sending json data from nodejs to r using r-integration

I'm currently using NodeJS and using r-integration. I'm trying to send this sample JSON

var jsonobj={"month": "january", "totalrevenue": 1000000}

from nodejs to Rstudio by R.callMethod.

In R.file,

library(rjson)
library(plyr)
x = function(data) {
  sample <- rjson::fromJSON(data)
  return (ex)
}

where data is the jsonobj.

The function just returns the JSON data as a complete string as supposed to how it is. Given below is how the output is in node js.

[ '{month:august,totalrevenue:78841814.37}' ]

The code gives me the following error

Error in rjson::fromJSON(data) : not all data was parsed (0 chars were parsed out of a total of 39 chars)

How can I fetch the JSON back from R exactly as it is passed from NodeJS?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source