I'm a newb here to so please correct me if I'm wrong, but if you're
running the HttpServer in the Dart VM then the
HttpRequest#queryParameters is a Map you can access.
http://api.dartlang.org/io/HttpRequest.html#get:queryParameters
Otherwise, if you've just got access to the string you could do
something like this:
String query = "foo=bar&x=y";
// Split the query into pieces
List pieces = query.split("&").map((e) => e.split("="));
// Convert the pieces into a map
Map params = {};
pieces.forEach((piece) => params[piece[0]] = piece[1]);
print(params);
Hope that helps. Curious to see if anyone knows a better way?
As for the split-workaround: you still need to html-unescape the
values like %30 and '+' encodings...
Regards,
Istvan
On Wed, Apr 18, 2012 at 2:03 PM, Mark Bennett <mark.f....@gmail.com> wrote:
Good to know, thanks Bob.
I went ahead and added a feature request to Uri to parse query params
into a Map.
http://code.google.com/p/dart/issues/detail?id=2645
Is there a process for contributing a patch to add this myself?
I may have gotten a little carried away and added a few other requests
as well that stemmed from thinking about this issue.
http://code.google.com/p/dart/issues/detail?id=2641
http://code.google.com/p/dart/issues/detail?id=2642
http://code.google.com/p/dart/issues/detail?id=2643
http://code.google.com/p/dart/issues/detail?id=2644