How to extract parameters from a URL?¶
Observe can parse a URL into a JSON array, and then extract the elements of that array to get parameters. There is no parse_query_params function.
To parse the URL, use the following OPAL statement:
make_col parsedUrl:parse_url(url)
This will create a new column called parsedUrl that contains a JSON array of the URL parts.
You can then extract the parameters into their own JSON array, and filter out ones that are empty:
make_col parameters:parsedUrl.parameters
filter parameters != "null"
If you only want a specific parameter name, that can be done from the url
object as well:
make_col key1:string(parsedUrl.parameters.key1),
key2:string(parsedUrl.parameters.key2)