jsonedit provides a flexible and helpful interactive tree-like view of lists or really any R dataset that can be represented as JSON. Eventually, this could become a very nice way to not only view but also modify R data using Shiny.

jsonedit(
  listdata = NULL,
  mode = "tree",
  modes = c("text", "tree", "table"),
  ...,
  width = NULL,
  height = NULL,
  elementId = NULL
)

Arguments

listdata

list or String data to view. Although designed for lists, listdata can be any data source that can be rendered into JSON with jsonlite. Alternately, listdata could be a String of valid JSON. This might be helpful when dealing with an API response.

mode

string for the initial view from modes. 'tree' is the default.

modes

string c('tree', 'text', 'table') will be the default, since these are all the modes currently supported by jsoneditor.

...

list of other options for jsoneditor. This is a temporary way of trying other options in jsoneditor. In the future, this will be eliminated in favor of specific, more self-documenting and helpful arguments.

width

integer in pixels defining the width of the div container.

height

integer in pixels defining the height of the div container.

elementId

character to specify valid CSS id of the htmlwidget for special situations in which you want a non-random identifier.

Examples

   library(listviewer)

   # using the data from the jsoneditor simple example
   #  in R list form
   jsonedit(
     list(
       array = c(1,2,3)
       ,boolean = TRUE
       ,null = NULL
       ,number = 123
       ,object = list( a="b", c="d" )
       ,string = "Hello World"
     )
   )
# jsonedit also works with a JSON string jsonedit( '{"array" : [1,2,3] , "boolean" : true, "null" : null, "number": 123}' )
# also works with most data.frames jsonedit( mtcars )
# helpful interactive view of par jsonedit( par() )