Format a ts_tree object for printing.
Usage
# S3 method for class 'ts_tree'
format(x, n = 10, ...)Details
This is the engine of print.ts_tree(),
possibly useful to obtain a printed representation without doing the
actual printing.
If there are selected nodes in the tree, those will be highlighted
in the output. See ts_tree_select() to
select nodes in a tree.
See also
Other ts_tree generics:
[[.ts_tree(),
[[<-.ts_tree(),
print.ts_tree(),
select-set,
ts_tree_ast(),
ts_tree_delete(),
ts_tree_dom(),
ts_tree_format(),
ts_tree_insert(),
ts_tree_new(),
ts_tree_query(),
ts_tree_select(),
ts_tree_sexpr(),
ts_tree_unserialize(),
ts_tree_update(),
ts_tree_write()
Examples
# Create a parse tree with tsjsonc -------------------------------------
json <- tsjsonc::ts_parse_jsonc(
'{ "a": 1, "b": [10, 20, 30], "c": { "c1": true, "c2": 100 } }'
)
format(json)
#> [1] "\033[90m# jsonc (1 line)\033[39m"
#> [2] "\033[90m1\033[39m\033[90m | \033[39m{ \"a\": 1, \"b\": [10, 20, 30], \"c\": { \"c1\": true, \"c2\": 100 } }"