Xbasic

Extension::URIQuery Class

Description

Parse and convert the query parameters from a URI string.

Discussion

The extension::URIQuery Class is a utility class that makes it very easy to parse name/value pairs in a 'query string'. The following Interactive Window session demonstrates use of this class:

dim qs as c = "name=fred&city=boston&country=&age=25"
dim postQ as extension::URIQuery
postQ.ParseURIQuery(qs)
?qs
= "name=fred&city=boston&country=&age=25"

?postq.age
= "25"

?postq.country
= ""

?postq.ToJson()
= {"name":"fred","city":"boston","country":"","age":"25"}

Methods

BuildHeaders Method

Build URIQuery query into headers.

BuildURIQuery Method

Build parts query into a URI (for inclusion in a URI).

Data Method

Get data for name (returns empty string if no data exists).

FromJson Method

JSON Content passed in (oAuth 2.0 passes back as json, not posted).

ParseHeaders Method

Parse header into URIQuery.

ParseURIQuery Method

Parse a URI query into separate parts.

SetData Method

Set data given a name.

ToJson Method

Create JSON from uriQuery.

See Also