Firstly, I am sending some parameters and with the response JSON String I am doing some conversions and adding it into list and then from spring controller passing it to JSP.
So, In my JSP I am using a for loop to render the data like,
<c:forEach var="treeList" items="${JSONResult.jsonList}" varStatus='treeStatus'>
{ "title": "<c:out value='${treeList.name}' />", "key": "<c:out value='${treeList.id}' />" }
<c:if test="${!(treeStatus.last)}">,</c:if>
</c:forEach>
with this I am getting JSON Error as,
SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data
But if I put the simple data like,
{ "title": "Node 1", "key": "1" }
Then It is working fine.
Also, I kept alert on error as XMLResponse.toSource() and I see like,
\r and \n appended a lot.
Please help me out why it is not accepting the response.
Your provided code will output the following,
You need to surround that with another set of brackets
A well formed object starts with a bracket and ends with a bracket, you are sending multiple objects delimited by commas whihich is not correct.
So a coorect version will look like,