jsonview : View formatted and "pretty printed" JSON or lists in R

(if you need XML viewing in R check out jsonview's sister package, xmlview)

It is intended for interactive use. When working with gnarly lists or JSON data, it's often times advantageous to be able to see the document in a more formatted way.

You can pass in:

and view the formatted & pretty-printed result in the RStudio viewer or web browser.

Here's an example of the collapsable tree view generaged by:

json_tree_view(fromJSON("https://collector.torproject.org/index/index.json"))

The widget uses vkbeautify, highlight.js and jquery.json-treeview to do all the work.

The following functions are implemented:

News

Installation

devtools::install_github("hrbrmstr/jsonview")
options(width=120)

Usage

library(xmlview)
library(jsonlite)

# available styles
highlight_styles()

# plain character
txt <- '{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}'

json_view(txt)
json_tree_view(txt)

doc <- fromJSON(txt)
json_view(doc, style="obsidian")
json_tree_view(doc)

json_view(readLines("https://collector.torproject.org/index/index.json", warn=FALSE))

json_tree_view(readLines("https://collector.torproject.org/index/index.json", warn=FALSE))

json_tree_view(fromJSON("https://collector.torproject.org/index/index.json"))

json_view(fromJSON("https://collector.torproject.org/index/index.json",
                   simplifyVector=FALSE))


hrbrmstr/jsonview documentation built on May 17, 2019, 5:10 p.m.