View source: R/data.tree-conversion.R
treeToJSON | R Documentation |
Walk through a data.tree
and constructs a JSON string,
which can be rendered by shinyTree.
treeToJSON(
tree,
keepRoot = FALSE,
topLevelSlots = c("default", "all"),
createNewId = TRUE,
pretty = FALSE
)
tree |
the data.tree which should be parses |
keepRoot |
logical. If |
topLevelSlots |
determines which slots should be moved to the top level of the
node. If |
createNewId |
logical. If |
pretty |
logical. If |
The JSON string generated follows the jsTree specifications. In particular it encodes children nodes via the ‘children’ slot.
All atomic or list slots of a node in the tree are stored in a data slot in the resulting JSON.
If the user wants to store some slots not in the data slot but on the top
level of the node, parameter topLevelSlots
can be used. This is useful
for additional parameters such as ‘icon’, ‘li_attr’ or
‘a_attr’, which jsTree expect to be on the top level of the node.
An example of how to make use of this functionality can be found in the example folder of this library.
a JSON string representing the data.tree
updateTree
and renderTree
need an unevaluated JSON
string. Hence, this function returns a string rather than the JSON object itself.
Thorn Thaler, thorn.thaler@thothal.at
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.