Convert a dataframe to JSON

It handles numerics, characters, factors, and logicals.


df2json is an R package to convert a dataframe to a JSON object.

It handles numerics, characters, factors, and logicals.

Install

install.packages("devtools")
library(devtools)
install_github("df2json","nachocab")

Usage

library(df2json)
df <- data.frame(name=c("a", "b", "c"), x=c(NA, 2 ,3), y=c(10, 20, -Inf), show=c(TRUE, FALSE, TRUE))
df2json(df)

The result is

[{"name":"a","x":null,"y":10,"show":true},
 {"name":"b","x":2,"y":20,"show":false},
 {"name":"c","x":3,"y":null,"show":true}]

News

df2json 0.0.2

  • Added json2df
  • Added matrix2json

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("df2json")

0.0.2 by Nacho Caballero, 6 years ago


http://github.com/nachocab/df2json


Browse source code at https://github.com/cran/df2json


Authors: Nacho Caballero <[email protected]>


Documentation:   PDF Manual  


GPL-3 license


Depends on rjson

Suggests testthat, roxygen2


See at CRAN