Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6543395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:20:31+00:00 2026-05-25T11:20:31+00:00

Firstly, I am sending some parameters and with the response JSON String I am

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:20:31+00:00Added an answer on May 25, 2026 at 11:20 am

    Your provided code will output the following,

    { "title": "Node 1", "key": "1" },
    { "title": "Node 2", "key": "2" },
    { "title": "Node 3, "key": "3" }
    

    You need to surround that with another set of brackets

    {"data": [
    <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>
    ]}
    

    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.

    Proper json object

    So a coorect version will look like,

    { "data": [{ "title": "Node 1", "key": "1" },
     { "title": "Node 2", "key": "2" },
     { "title": "Node 3, "key": "3" }
    ]}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly - my description ;) I've got a XmlHttpRequests JSON response from the server.
Firstly, I'm some what new to C++/CLI . After doing some research I've found
Firstly, I was wondering if there was some kind of built in function that
i have a design issue regarding sending user data from a mobile phone app
Firstly I design the site & convert it into HTML using Twitter bootstrap. The
Firstly, I have migrated my CVS repository into SVN repository. I checked out this
Firstly, I have found many examples of how to grab data from a db
Firstly, let me say that I know that http://sphinxsearch.com/docs/current.html#conf-sql-attr-string says strings can only be
Firstly, there have some tag links in my main page. click each one, post
Firstly, I've read through the posts with matching names, and I've tried integrating some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.