having problems parsing JSON

Discussion in 'Javascript' started by paulfe4@gmail.com, Apr 22, 2006.

  1. Guest

    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?

    thanks,

    ../paul
     
    , Apr 22, 2006
    #1
    1. Advertising

  2. Guest

    oh - nevermind - the frackin' semicolon was killing me.
     
    , Apr 22, 2006
    #2
    1. Advertising

  3. VK Guest

    wrote:
    > oh - nevermind - the frackin' semicolon was killing me.


    Actually you should use the default JSON parser and stringifier
    <http://www.json.org/js.html> 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++ ;-)
     
    VK, Apr 22, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Florian Frank
    Replies:
    0
    Views:
    250
    Florian Frank
    Jun 30, 2009
  2. sajuptpm
    Replies:
    2
    Views:
    356
    sajuptpm
    Dec 28, 2012
  3. Acácio Centeno
    Replies:
    1
    Views:
    276
    dieter
    Feb 15, 2013
  4. Bryan Britten
    Replies:
    9
    Views:
    275
    Bryan Britten
    May 28, 2013
  5. David Karr
    Replies:
    1
    Views:
    176
    David Karr
    Jun 17, 2013
Loading...

Share This Page