By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,179 Members | 2,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,179 IT Pros & Developers. It's quick & easy.

having problems parsing JSON

P: n/a
i have an ajax request, where the server is returning:

{"PageDef": {
"pageName": "myname",
"queryName": "myqueryname",
"queryCtName": "myqueryctname"

i have the following code handling it:

var jsontext = response.responseText;
alert( '(' + jsontext + ')' );
var jsonObj = eval( '(' + jsontext + ')' );
doSomethingWithObj( jsonObj );

the alert shows the returned content perfectly. but the eval does not
work. i'm getting "missing ) in parenthetical." for a long time i had
"not well-formed", and trying to include "var jsonObj = " in the
return, i would get "syntax error" i think. taking out the '(' an ')'
from the eval statement, i get "invalid label".

i looked around in a lot of places, but could not find anything
definitive on what *exactly* the server's JSON-formatted response
should look like.

can someone help me out?



Apr 22 '06 #1
Share this Question
Share on Google+
2 Replies

P: n/a
oh - nevermind - the frackin' semicolon was killing me.

Apr 22 '06 #2

P: n/a
pa***** wrote:
oh - nevermind - the frackin' semicolon was killing me.

Actually you should use the default JSON parser and stringifier
<> and contact the producer if something
looks like a per design fault.

I mean of course you are free to write your very own code, but it is
not acommon way (you don't write C+++ from the scratch just because you
had some problem with C++ ;-)

Apr 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.