I have a parameter in my grails view which I am passing to javascript code
<g:if test="${replacedString}">
${replacedString}
<g:set var="replacedString" value="${replacedString}"/>
</g:if>
<script>
var mydata = decodeURIComponent(${replacedString});
console.log(mydata);
</script>
The replacedString value is being passed as an encoded string i.e: " appears as "
.
Due to this I have the method
decodeURIComponent
This is the string I'm trying to decode:
[{"description":"test1 ","filenameAndPath":"test1.pdf"},{"description":"test file","filenameAndPath":"test copy.pdf"},{"description":"","filenameAndPath":""},{"description":"","filenameAndPath":""}]
This block of code keeps throwing the error Syntax error: Unexpected token &
.
Am I missing something obvious ?