Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting message as Invalid JSON

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I am creating a JSON Data inside my servlet , as shwon :



This is my JSP Page using Juery


I am getting mesage as Invalid JSON
to validate the json i have used http://www.jsonlint.com/

and it showed a parse error as

syntax error, unexpected TINVALID, expecting TSTRING or '}' at line 2
Parsing failed


please tell me how to solve this
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would certainly write that String that is supposed to be JSON to a log file in addition to sending it to the response so it can be examined carefully.

Trying to figure out what was actually written by looking at the code is unlikely to spot the flaw.

Bill
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i solved it by changing jquery version to 1.3 from 1.5 .
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd hardly called that "solved". Do you really think that makes sense as opposed to fixing the invalid JSON?
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would suggest using the Java APIs for JSON. Those are available at Java JSON API. That will help you not to get these kind of errors.

Regds,
Amit
 
parampreet sethi
Greenhorn
Posts: 27
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Amit. I have used Java JSON API for generating response for DMOZ API (www.dmoz.org) and it works great and very easy to use.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic