Loading ...
Sorry, an error occurred while loading the content.

[question] parse json with ajax

Expand Messages
  • genzoeri
    Hi,I have difficulties to parse this json {depth1:{depth2:{depth3: content }}} how to get the content ?? using ajax?
    Message 1 of 7 , Aug 14, 2007
    • 0 Attachment
      Hi,I have difficulties to parse this json
      {depth1:{depth2:{depth3:'content'}}}
      how to get the 'content'?? using ajax?
    • Crzy4C
      well you don t get content using ajax. You get content using javascript... if that json string was assigned to a variable foo... var foo = {depth1 : {
      Message 2 of 7 , Aug 14, 2007
      • 0 Attachment
        well you don't get "content" using ajax. You get "content" using
        javascript...
        if that json string was assigned to a variable foo...
        var foo = {depth1 : { depth2 : {depth3 : 'content'}}};
        and you set...
        var foo1 = foo.depth1.depth2.depth3;
        then the value of foo1 would be 'content;

        Mike

        genzoeri wrote:
        >
        > Hi,I have difficulties to parse this json
        > {depth1:{depth2:{depth3:'content'}}}
        > how to get the 'content'?? using ajax?
        >
        >



        [Non-text portions of this message have been removed]
      • Martin Cooper
        ... That s not valid JSON, for two reasons: 1) Key names are strings, and must be quoted as such. 2) Strings must be quoted with double quotes, not single
        Message 3 of 7 , Aug 14, 2007
        • 0 Attachment
          On 8/14/07, genzoeri <genzoeri@...> wrote:
          >
          > Hi,I have difficulties to parse this json
          > {depth1:{depth2:{depth3:'content'}}}


          That's not valid JSON, for two reasons:

          1) Key names are strings, and must be quoted as such.
          2) Strings must be quoted with double quotes, not single quotes.

          See http://json.org/ for the JSON specification.

          --
          Martin Cooper


          how to get the 'content'?? using ajax?
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >


          [Non-text portions of this message have been removed]
        • genzoeri
          I will use this for my AJAX. Using responsetext properties from XHR. ... btw, thank you for your response. I am glad, I am on the right place.
          Message 4 of 7 , Aug 14, 2007
          • 0 Attachment
            I will use this for my AJAX. Using responsetext properties from XHR.
            :) ok,then how to parse, {"depth1":{"depth2":{"depth3":"content"}}} ??
            btw, thank you for your response. I am glad, I am on the right place.
            --- In json@yahoogroups.com, "Martin Cooper" <mfncooper@...> wrote:
            >
            > On 8/14/07, genzoeri <genzoeri@...> wrote:
            > >
            > > Hi,I have difficulties to parse this json
            > > {depth1:{depth2:{depth3:'content'}}}
            >
            >
            > That's not valid JSON, for two reasons:
            >
            > 1) Key names are strings, and must be quoted as such.
            > 2) Strings must be quoted with double quotes, not single quotes.
            >
            > See http://json.org/ for the JSON specification.
            >
            > --
            > Martin Cooper
            >
            >
            > how to get the 'content'?? using ajax?
            > >
            > >
            > >
            > >
            > > Yahoo! Groups Links
            > >
            > >
            > >
            > >
            >
            >
            > [Non-text portions of this message have been removed]
            >
          • Mark Ireland
            Key names must be quoted and cant start with a number?Is that right?To: json@yahoogroups.comFrom: mfncooper@gmail.comDate: Tue, 14 Aug 2007 19:11:32
            Message 5 of 7 , Aug 14, 2007
            • 0 Attachment
              Key names must be quoted and cant start with a number?Is that right?To: json@yahoogroups.comFrom: mfncooper@...: Tue, 14 Aug 2007 19:11:32 -0700Subject: Re: [json] [question] parse json with ajax


















              On 8/14/07, genzoeri <genzoeri@...> wrote:
              >
              > Hi,I have difficulties to parse this json
              > {depth1:{depth2:{depth3:'content'}}}

              That's not valid JSON, for two reasons:

              1) Key names are strings, and must be quoted as such.
              2) Strings must be quoted with double quotes, not single quotes.

              See http://json.org/ for the JSON specification.

              --
              Martin Cooper

              how to get the 'content'?? using ajax?
              >
              >
              >
              >
              > Yahoo! Groups Links
              >
              >
              >
              >

              [Non-text portions of this message have been removed]
















              _________________________________________________________________
              Explore the seven wonders of the world
              http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE

              [Non-text portions of this message have been removed]
            • Michal Migurski
              ... This should help: eval( var responsejson = ( + responsetext + ); ); alert(responsejson[ depth1 ][ depth2 ][ depth3 ]; ... Yes. -mike. ... michal
              Message 6 of 7 , Aug 15, 2007
              • 0 Attachment
                On Aug 14, 2007, at 11:34 PM, genzoeri wrote:
                > I will use this for my AJAX. Using responsetext properties from XHR.
                > :) ok,then how to parse, {"depth1":{"depth2":{"depth3":"content"}}} ??
                > btw, thank you for your response. I am glad, I am on the right place.

                This should help:
                eval("var responsejson = (" + responsetext + ");");
                alert(responsejson['depth1']['depth2']['depth3'];



                On Aug 14, 2007, at 11:58 PM, Mark Ireland wrote:
                > Key names must be quoted and cant start with a number?Is that right?

                Yes.

                -mike.

                ----------------------------------------------------------------
                michal migurski- contact info and pgp key:
                sf/ca http://mike.teczno.com/contact.html
              • Philip Tellis
                ... Ugh, don t do that. Apart from screwing with the scope of responsejson, it also causes a security problem, and it s overkill. If you must use eval, do it
                Message 7 of 7 , Aug 15, 2007
                • 0 Attachment
                  On 15/08/07, Michal Migurski <mike-jsonphp@...> wrote:
                  >
                  > This should help:
                  > eval("var responsejson = (" + responsetext + ");");
                  > alert(responsejson['depth1']['depth2']['depth3'];

                  Ugh, don't do that. Apart from screwing with the scope of
                  responsejson, it also causes a security problem, and it's overkill.
                  If you must use eval, do it this way:

                  var responsejson = eval( "(" + o.responseText + ")" );

                  That won't take away the security problems with eval, but it will make
                  sure that responsejson is in current scope.
                Your message has been successfully submitted and would be delivered to recipients shortly.