aspose file tools*
The moose likes Servlets and the fly likes Getting message as Invalid JSON Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting message as Invalid JSON" Watch "Getting message as Invalid JSON" New topic
Author

Getting message as Invalid JSON

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

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


Save India From Corruption - Anna Hazare.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
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

Joined: Apr 18, 2009
Posts: 2234

i solved it by changing jquery version to 1.3 from 1.5 .
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

I'd hardly called that "solved". Do you really think that makes sense as opposed to fixing the invalid JSON?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 515
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

Joined: Aug 03, 2009
Posts: 27

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.


Param
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting message as Invalid JSON