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

Re: [json] JSON text not parsing on FireFox

Expand Messages
  • Ashwin Prabhu
    Hi Henrik and Martin, Thanks very much for your response. Without quotes its working for me. With quotes FireFox is throwing an error as invalidLabel , when
    Message 1 of 11 , Jun 13 11:53 AM
    • 0 Attachment
      Hi Henrik and Martin,

      Thanks very much for your response.
      Without quotes its working for me.
      With quotes FireFox is throwing an error as 'invalidLabel', when the
      'eval' method is called.

      Things are working now :)

      - Ashwin


      On Jun 13, 2006, at 9:31 AM, henrik hjelte wrote:

      > This is javascript code, not JSON. Keys should have surrounding quotes
      > in JSON.
      >
      > {"user": {"errorFirstName":"", "errorLastName::"", "errorEmail":"The
      > email address you entered is not valid." } }
      >
      > /Henrik Hjelte
      >
      > On mån, 2006-06-12 at 22:39 +0000, Ashwin Prabhu wrote:
      >> Hi,
      >>
      >> My JSON text looks as below:
      >>
      >> myJSONtext = {user: {errorFirstName:"", errorLastName:"",
      >> errorEmail:"The email address you entered is not valid." } };
      >>
      >> But when i try to fetch the values it gives an error as
      >> invalidLabel.. not sure why this is happening?
      >> Value is fetched as myJSONtext.user.errorFirstName.
      >>
      >> Also i tried creating an array as in the example on http://
      >> www.json.org/js.html
      >>
      >> But still it gives myJSONtext.user has no properties.
      >>
      >> Any hint what am i doing wrong.
      >>
      >> - Ashwin
      >>
      >>
      >>
      >>
      >>
      >
      >
      >
      > ------------------------ Yahoo! Groups Sponsor --------------------
      > ~-->
      > Home is just a click away. Make Yahoo! your home page now.
      > http://us.click.yahoo.com/DHchtC/3FxNAA/yQLSAA/1U_rlB/TM
      > --------------------------------------------------------------------
      > ~->
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
    • Douglas Crockford
      ... Why are you using eval?
      Message 2 of 11 , Jun 13 9:02 PM
      • 0 Attachment
        > With quotes FireFox is throwing an error as 'invalidLabel', when the
        > 'eval' method is called.

        Why are you using eval?
      • Ashwin Prabhu
        Hi Doug, My understanding of JSON was that you need to form a Text in such way that, when we create a JSON object using eval , then we can traverse its
        Message 3 of 11 , Jun 15 11:40 AM
        • 0 Attachment
          Hi Doug,

          My understanding of JSON was that you need to form a Text in such way
          that, when we create a JSON object using 'eval', then we can
          traverse its properties using aJSONObject.attributeName.
          So instead of returning XML and parsing it (which i have done before
          in javascript ), i am returning this text and then converting it
          into a JSON object.
          Am i thinking wrong! Please correct me.

          Thanks.

          - Ashwin

          On Jun 13, 2006, at 9:02 PM, Douglas Crockford wrote:

          >> With quotes FireFox is throwing an error as 'invalidLabel', when the
          >> 'eval' method is called.
          >
          > Why are you using eval?
          >
          >
          >
          >
          >
          > ------------------------ Yahoo! Groups Sponsor --------------------
          > ~-->
          > You can search right from your browser? It's easy and it's free.
          > See how.
          > http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/1U_rlB/TM
          > --------------------------------------------------------------------
          > ~->
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
          >
          >
        • Michal Migurski
          ... It would be helpful to have some more context; the first snippet you sent was just plain old Javascript, and didn t show how you re using eval(). -mike.
          Message 4 of 11 , Jun 15 12:00 PM
          • 0 Attachment
            > My understanding of JSON was that you need to form a Text in such way
            > that, when we create a JSON object using 'eval', then we can
            > traverse its properties using aJSONObject.attributeName.
            > So instead of returning XML and parsing it (which i have done before
            > in javascript ), i am returning this text and then converting it
            > into a JSON object.
            > Am i thinking wrong! Please correct me.
            It would be helpful to have some more context; the first snippet you
            sent was just plain old Javascript, and didn't show how you're using
            eval().

            -mike.

            ------------------------------------------------------
            michal migurski- contact info, blog, and pgp key:
            sf/ca http://mike.teczno.com/contact.html
          • Matthew Morley
            Perhaps he is asking why you aren t using: http://json.org/json.js ... string.parseJSON() This method parses a JSON text to produce an object or array. It will
            Message 5 of 11 , Jun 15 12:05 PM
            • 0 Attachment
              Perhaps he is asking why you aren't using:

              http://json.org/json.js
              -----------------------------------------------------
              string.parseJSON()

              This method parses a JSON text to produce an object or
              array. It will return false if there is an error.
              --
              Matt (MPCM)
            • keelypavan
              Ashwin, ... You directly have Javascript statement for object and there was no need for eval ing it. That was Doug s point. Pavan Keely
              Message 6 of 11 , Jun 15 12:08 PM
              • 0 Attachment
                Ashwin,

                This confusion came up because in the sample code you provided:

                > myJSONtext = {user: {errorFirstName:"", errorLastName:"",
                > errorEmail:"The email address you entered is not valid." } };

                You directly have Javascript statement for object and there was no
                need for 'eval'ing it. That was Doug's point.

                Pavan Keely

                --- In json@yahoogroups.com, "Matthew Morley" <WickedLogic@...> wrote:
                >
                > Perhaps he is asking why you aren't using:
                >
                > http://json.org/json.js
                > -----------------------------------------------------
                > string.parseJSON()
                >
                > This method parses a JSON text to produce an object or
                > array. It will return false if there is an error.
                > --
                > Matt (MPCM)
                >
              • Todd Kingham
                Ashwin, It sounds like either your eval() statement is incorrect or your JSON string is malformatted. Below is a simple example of some JSON written in
                Message 7 of 11 , Jun 15 12:14 PM
                • 0 Attachment
                  Ashwin,

                  It sounds like either your eval() statement is incorrect or your JSON string
                  is malformatted.

                  Below is a simple example of some JSON written in JavaScript that I know
                  will work in Firefox.

                  var JSONstr = '{keyOne:"Alpha",keyTwo:"Omega"}';
                  var JSONvar = eval('('+JSONstr+')');
                  alert(JSONvar.keyOne);

                  This should work if you replace the JSONstr variable I'm setting here with a
                  JSON string dynamically built on the server and passed in.

                  HTH,
                  -Todd



                  On 6/15/06, Ashwin Prabhu <aprabhu1@...> wrote:
                  >
                  > Hi Doug,
                  >
                  > My understanding of JSON was that you need to form a Text in such way
                  > that, when we create a JSON object using 'eval', then we can
                  > traverse its properties using aJSONObject.attributeName.
                  > So instead of returning XML and parsing it (which i have done before
                  > in javascript ), i am returning this text and then converting it
                  > into a JSON object.
                  > Am i thinking wrong! Please correct me.
                  >
                  > Thanks.
                  >
                  > - Ashwin
                  >
                  > On Jun 13, 2006, at 9:02 PM, Douglas Crockford wrote:
                  >
                  > >> With quotes FireFox is throwing an error as 'invalidLabel', when the
                  > >> 'eval' method is called.
                  > >
                  > > Why are you using eval?
                  > >
                  > >
                  > >
                  > >
                  > >
                  > > ------------------------ Yahoo! Groups Sponsor --------------------
                  > > ~-->
                  > > You can search right from your browser? It's easy and it's free.
                  > > See how.
                  > > http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/1U_rlB/TM
                  > > ----------------------------------------------------------
                  > > ~->
                  > >
                  > >
                  > > Yahoo! Groups Links
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  >
                  >
                  >


                  [Non-text portions of this message have been removed]
                • Ashwin Prabhu
                  Hey Guys, Thanks very much for all the clarifications. i think, i know what i was doing wrong. As for parseJSON, yup i will using that. Thanks again! -
                  Message 8 of 11 , Jun 16 8:55 AM
                  • 0 Attachment
                    Hey Guys,

                    Thanks very much for all the clarifications. i think, i know what i
                    was doing wrong.
                    As for parseJSON, yup i will using that.

                    Thanks again!

                    - Ashwin

                    On Jun 15, 2006, at 12:08 PM, keelypavan wrote:

                    > Ashwin,
                    >
                    > This confusion came up because in the sample code you provided:
                    >
                    >> myJSONtext = {user: {errorFirstName:"", errorLastName:"",
                    >> errorEmail:"The email address you entered is not valid." } };
                    >
                    > You directly have Javascript statement for object and there was no
                    > need for 'eval'ing it. That was Doug's point.
                    >
                    > Pavan Keely
                    >
                    > --- In json@yahoogroups.com, "Matthew Morley" <WickedLogic@...> wrote:
                    >>
                    >> Perhaps he is asking why you aren't using:
                    >>
                    >> http://json.org/json.js
                    >> -----------------------------------------------------
                    >> string.parseJSON()
                    >>
                    >> This method parses a JSON text to produce an object or
                    >> array. It will return false if there is an error.
                    >> --
                    >> Matt (MPCM)
                    >>
                    >
                    >
                    >
                    >
                    >
                    >
                    >
                    > ------------------------ Yahoo! Groups Sponsor --------------------
                    > ~-->
                    > Great things are happening at Yahoo! Groups. See the new email
                    > design.
                    > http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/1U_rlB/TM
                    > --------------------------------------------------------------------
                    > ~->
                    >
                    >
                    > Yahoo! Groups Links
                    >
                    >
                    >
                    >
                    >
                    >
                  Your message has been successfully submitted and would be delivered to recipients shortly.