Revision: 61267
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 3, 2012 04:59 by laurenceosx
Initial Code
def urlEncodeMap( aMap ) { // e.g. given map [x:1, y2] returns x=1&y=2 def encode = { URLEncoder.encode( "$it".toString() ) } return aMap.collect { encode(it.key) + '=' + encode(it.value) }.join('&') } def urlDecodeToMap( aUrlEncodedStr ) { def result = [:] def decode = { URLDecoder.decode(it) } def ampSplit = aUrlEncodedStr.tokenize('&') ampSplit.each { def eqSplit = it.tokenize('=') result[ decode(eqSplit[0]) ] = decode(eqSplit[1]) } return result; }
Initial URL
Initial Description
lpt
Initial Title
Groovy UrlEncode and UrlDecode a map
Initial Tags
Initial Language
Groovy