json_tree_view: JSON tree viewer

Description Usage Arguments Details Examples

View source: R/jsontreeview.r

Description

Pass in a plaintext JSON or an R list to see formatted JSON in a viewer.

Usage

1
2
json_tree_view(x, auto_unbox = TRUE, scroll = FALSE, elementId = NULL,
  width = "100%", height = NULL)

Arguments

x

plaintext JSON or an R list

auto_unbox

passed to fromJSON (more on this when I have time for documentation)

scroll

should the <div> holding the HTML/XML content scroll (TRUE) or take up the full viewer/browser window (FALSE). Default is FALSE (take up the full viewer/browser window). If this is set to TRUE, height should be set to a value other than NULL.

elementId

element id

width

widget width (best to keep it at 100%)

height

widget height (kinda only useful for knitting since this is meant to be an interactive tool).

Details

It uses the jsonlite package to deal with gnarly lists (h/t @jennybryan).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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_tree_view(txt)

doc <- fromJSON(txt)
json_tree_view(doc)
## Not run: 
json_tree_view(readLines("https://collector.torproject.org/index.json",
                    warn=FALSE))

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

## End(Not run)

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