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 42 43 44 45 46 47
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{parseQueryString}
\alias{parseQueryString}
\title{Parse a GET query string from a URL}
\usage{
parseQueryString(str, nested = FALSE)
}
\arguments{
\item{str}{The query string. It can have a leading \code{"?"} or not.}
\item{nested}{Whether to parse the query string of as a nested list when it
contains pairs of square brackets \code{[]}. For example, the query
\samp{a[i1][j1]=x&b[i1][j1]=y&b[i2][j1]=z} will be parsed as \code{list(a =
list(i1 = list(j1 = 'x')), b = list(i1 = list(j1 = 'y'), i2 = list(j1 =
'z')))} when \code{nested = TRUE}, and \code{list(`a[i1][j1]` = 'x',
`b[i1][j1]` = 'y', `b[i2][j1]` = 'z')} when \code{nested = FALSE}.}
}
\description{
Returns a named list of key-value pairs.
}
\examples{
parseQueryString("?foo=1&bar=b\%20a\%20r")
\dontrun{
# Example of usage within a Shiny app
function(input, output, session) {
output$queryText <- renderText({
query <- parseQueryString(session$clientData$url_search)
# Ways of accessing the values
if (as.numeric(query$foo) == 1) {
# Do something
}
if (query[["bar"]] == "targetstring") {
# Do something else
}
# Return a string with key-value pairs
paste(names(query), query, sep = "=", collapse=", ")
})
}
}
}
|