I am pushing some variables to a httpGet
statement and it is failing on any spaces, how can I replace the spaces in the variable with %20
prior to running the GET?
I am trying to encode "felton, ca" which is in the variable from
with def fromFormatted = URLEncoder.encode(from, "UTF-8")
and when I run the code I get the error
groovy.lang.MissingMethodException: No signature of method: static java.net.URLEncoder.encode() is applicable for argument types: (org.codehaus.groovy.grails.web.json.JSONArray, java.lang.String) values: [[felton, ca], UTF-8]
original input field
section("Departing From:"){
input "from", "text", title: "Address?"
Also tried def fromFormatted = from.encodeAsURL()
with the result of
%5B%22felton%22%2C%22ca%22%5D
apparently since the input text contained a ,
then it automatically treated that input text as an array. Any thoughts on keeping this from happening, or converting it to a string and maintaining the comma?
I resolved the array by using def fromStr = from.join(",")
unforunately join
creates a json string that adds double quotes
%22felton%22%2C%22ca%22
Is there another method for joining the array that would maintain the comma without adding quotes?