% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ts-tree-select.R
\name{[[.ts_tree}
\alias{[[.ts_tree}
\title{Unserialize parts of a tree-sitter tree}
\usage{
\method{[[}{ts_tree}(x, i, ...)
}
\arguments{
\item{x}{A \code{ts_tree} object.}

\item{i}{Selection expressions in a list, see details in
\code{\link[tsitter:ts_tree_select]{ts_tree_select()}}.}

\item{...}{Additional arguments, passed to
\code{\link[tsitter:ts_tree_select]{ts_tree_select()}}.}
}
\value{
List of R objects, with one entry for each selected element.
}
\description{
The \code{[[} operator works similarly to the combination of
\code{\link[tsitter:ts_tree_select]{ts_tree_select()}} and
\code{\link[tsitter:ts_tree_unserialize]{ts_tree_unserialize()}}, but it
might be more readable.
}
\details{
The following two expressions are equivalent:

\if{html}{\out{<div class="sourceCode r">}}\preformatted{ts_tree_unserialize(ts_tree_select(tree, <selectors>))
}\if{html}{\out{</div>}}

and

\if{html}{\out{<div class="sourceCode r">}}\preformatted{tree[[list(<selectors>)]]
}\if{html}{\out{</div>}}
\subsection{The \verb{[[<-} replacement operator}{

The \verb{[[<-} operator works similarly to the combination of
\code{\link[tsitter:ts_tree_select]{ts_tree_select()}} and
\code{\link[tsitter:ts_tree_update]{ts_tree_update()}}, (and also to the
replacement function \code{\link[tsitter:ts_tree_select<-]{ts_tree_select<-()}}),
but it might be more readable.
}
}
\examples{
\dontshow{if (requireNamespace("tsjsonc", quietly = TRUE)) withAutoprint(\{ # examplesIf}
# Create a parse tree with tsjsonc -------------------------------------
tree <- tsjsonc::ts_parse_jsonc('{"a": 13, "b": [1, 2, 3], "c": "x"}')

tree

tree[[list("a")]]

# Last two elements of "b"
tree[[list("b", -(1:2))]]
\dontshow{\}) # examplesIf}
}
\seealso{
Other ts_tree generics:
\code{\link[=[[<-.ts_tree]{[[<-.ts_tree()}},
\code{\link[=format.ts_tree]{format.ts_tree()}},
\code{\link[=print.ts_tree]{print.ts_tree()}},
\code{\link{select-set}},
\code{\link[=ts_tree_ast]{ts_tree_ast()}},
\code{\link[=ts_tree_delete]{ts_tree_delete()}},
\code{\link[=ts_tree_dom]{ts_tree_dom()}},
\code{\link[=ts_tree_format]{ts_tree_format()}},
\code{\link[=ts_tree_insert]{ts_tree_insert()}},
\code{\link[=ts_tree_new]{ts_tree_new()}},
\code{\link[=ts_tree_query]{ts_tree_query()}},
\code{\link[=ts_tree_select]{ts_tree_select()}},
\code{\link[=ts_tree_sexpr]{ts_tree_sexpr()}},
\code{\link[=ts_tree_unserialize]{ts_tree_unserialize()}},
\code{\link[=ts_tree_update]{ts_tree_update()}},
\code{\link[=ts_tree_write]{ts_tree_write()}}

Other serialization functions:
\code{\link[=ts_tree_unserialize]{ts_tree_unserialize()}}
}
\concept{serialization functions}
\concept{ts_tree generics}
