How to split strings into AA using phobos
Andre Pany
andre at s-e-a-p.de
Tue Dec 11 18:46:27 UTC 2018
On Tuesday, 11 December 2018 at 08:20:32 UTC, Arun Chandrasekaran
wrote:
> A typical example would be to split the HTTP query string into
> an AA.
>
> vibe.d has req.queryString, but no convenient wrapper to access
> it as an AA.
>
> http://localhost/hello?name=abc&id=123
>
> I've got this far.
>
> auto arr = req.queryString.splitter('&').map!(a =>
> a.splitter('='));
>
> Thanks
I am not 100% sure but I think query parameters names can occur
multiple times in query string.
Therefore you need an associative array with string as key and
string[] array as value.
By using associative array you loose the order of the parameters.
Whether this is important for query parameters I do not know.
Kind regards
Andre
More information about the Digitalmars-d-learn
mailing list