I propose using the awesome and performant jsonlite package which is specialized in JSON-R and R-JSON conversion:
# load package
library(jsonlite)
# get help
?toJSON
# do transformations
df <- data.frame(a=1:3, b=letters[1:3])
toJSON(df)
## [{"a":1,"b":"a"},{"a":2,"b":"b"},{"a":3,"b":"c"}]
toJSON(df, dataframe="rows")
## [{"a":1,"b":"a"},{"a":2,"b":"b"},{"a":3,"b":"c"}]
toJSON(df, dataframe="columns")
## {"a":[1,2,3],"b":["a","b","c"]}
toJSON(df, dataframe="values")
## [[1,"a"],[2,"b"],[3,"c"]]
PS.: The toJSON()
has further arguments to control and fine tune conversion.