digitalmars.D.learn - How to split strings into AA using phobos
- Arun Chandrasekaran (9/9) Dec 11 2018 A typical example would be to split the HTTP query string into an
- John Chapman (7/16) Dec 11 2018 req.queryString[req.queryString.indexOf('?') + 1 .. $]
- Andre Pany (10/19) Dec 11 2018 I am not 100% sure but I think query parameters names can occur
- Adam D. Ruppe (2/4) Dec 11 2018 Yes, that's right.
- Steven Schveighoffer (4/8) Dec 11 2018 Yeah it does:
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
Dec 11 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('=')); Thanksreq.queryString[req.queryString.indexOf('?') + 1 .. $] .splitter('&') .map!(a => a.splitter('=')) .map!(a => tuple(a.front, a.back)) .assocArray
Dec 11 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('=')); ThanksI 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
Dec 11 2018
On Tuesday, 11 December 2018 at 18:46:27 UTC, Andre Pany wrote:I am not 100% sure but I think query parameters names can occur multiple times in query string.Yes, that's right.
Dec 11 2018
On 12/11/18 3:20 AM, 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.Yeah it does: http://vibed.org/api/vibe.http.server/HTTPServerRequest.query -Steve
Dec 11 2018