R has a JSON package

Named rjson, appropriately. It’s quite basic just now, but contains methods for interconversion between R objects and JSON. Something like this:

library(rjson)
data <- list(a=1,b=2,c=3)
json <- toJSON(data)
json
[1] "{\"a\":1,\"b\":2,\"c\":3}"
cat(json, file="data.json")

Use cases? I wonder if RApache could be used to build an API that serves R data in JSON format?

2 thoughts on “R has a JSON package

  1. jmarca

    I just loaded and tried rjson myself, and immediately ran into problems parsing the output from couchdb. I had no problems with the similar RJSONIO from the omegahat project. You just have to make sure to tell R to use the omega hat project repository, as in

    install.packages(“RJSONIO”, repos = “http://www.omegahat.org/R”)

Comments are closed.