I have a url encoded string that is returned from an API I am using. I want to do something request.getParameter("paramname") on the string. What I'm looking for is something like str.request.getParameter("paramname"). There's gotta be something like this right?
clarification the api returns something like: name1=val1&name2=val2&name3=val3
I know i could do a split on "&" and then go through each element but that seems stupid. Please advise. Thanks!
Use URLEncodedUtils from Apache httpclient library.
API : http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/utils/URLEncodedUtils.html
You will have to call this method to get name value pairs:
static List<NameValuePair> parse(HttpEntity entity)
Returns a list of NameValuePairs as parsed from an HttpEntity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With