How to MQL query string into Tranlated URL?

347 views Asked by At

http://api.geoapi.com/v1/q

My query: {"lat": 37.75629, "lon": -122.4213, "radius": "1km", "entity": [{"type": "business", "guid": null}]}
http://api.geoapi.com/v1/q?q=%7B%22lat%22%3A+37.75629%2C+%22lon%22%3A+-122.4213%2C+%22radius%22%3A+%221km%22%2C+%22entity%22%3A+%5B%7B%22type%22%3A+%22business%22%2C+%22guid%22%3A+null%7D%5D%7D&apikey=demo&pretty=1

I am currently working on android. How to convert query string into parsed URL. Is there any tool translate URL for this? or otherwise i want to implement logic. I dont know whether my question right or wrong? can anyone help me.

1

There are 1 answers

0
Vladtn On BEST ANSWER

If I understand your question well, on Android, you can use

Uri uri=Uri.parse(url_as_string);
uri.getQueryParameter("param1");

or the Apache libraries provide a Query parser:

http://developer.android.com/reference/org/apache/http/client/utils/URLEncodedUtils.html and http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/utils/URLEncodedUtils.html

The method parse() returns a list of NameValuePairs as built from the URI's query portion.

If you want to convert parameters to a uri, use Uri.Builder:

Uri.Builder uri = new Uri.Builder().scheme("http").
        authority("test.com").
        path("theservlet").
        appendQueryParameter("q", theQuery);

Thanks to Will and diyism for the info.