Skip to content

Instantly share code, notes, and snippets.

@gluc
Created May 13, 2015 14:17
Show Gist options
  • Save gluc/156f6bafc9913b989d14 to your computer and use it in GitHub Desktop.
Save gluc/156f6bafc9913b989d14 to your computer and use it in GitHub Desktop.
Converting data.tree to JSON, simpler
#this has now become much simpler:
data(acme)
l <- acme$ToList()
#alternatively, you might prefer the "traditional" generic method:
l <- as.list(acme)
library(rjson)
j <- toJSON(l)
cat(j)
#as a side note: you can also convert a list to a Node:
a2 <- as.Node(l)
@gluc
Copy link
Author

gluc commented May 13, 2015

@timelyportfolio
Copy link

This is wonderful. I really appreciate it. With my little listviewer htmlwidget, you can do

#devtools::install_github("timelyportfolio/listviewer")
library(listviewer)

jsonedit(l)

and get a result like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment