output: html_document: keep_md: true md_document: variant: markdown_github
jsonview
: View formatted and "pretty printed" JSON or list
s 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:
list
object (any R object, really)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:
json_view
: view JSON, formatted & pretty-printedjson_tree_view
: view JSON in a collapsable tree viewjson_tree_view()
devtools::install_github("hrbrmstr/jsonview")
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.