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

JSON Parsing Problem

Expand Messages
  • mr_cebyrd
    I have a problem with using YUI s JSON parser in Internet Explorer(IE). I m using IE, version 6. I m able to use the parse method just fine in Firefox(By the
    Message 1 of 18 , Apr 1 1:08 PM
    • 0 Attachment
      I have a problem with using YUI's JSON parser in Internet
      Explorer(IE). I'm using IE, version 6. I'm able to use the parse
      method just fine in Firefox(By the way, I'm using YUI 2.5.1).
      However, when I try to use the JSON parser inside IE, I get unhandled
      exception errors. Any clues as to what could be causing this problem?
      Thanks in advance.
    • y_lsmith
      Do you have a sample page I could look at? Luke
      Message 2 of 18 , Apr 1 3:32 PM
      • 0 Attachment
        Do you have a sample page I could look at?

        Luke


        --- In ydn-javascript@yahoogroups.com, "mr_cebyrd" <mr_cebyrd@...> wrote:
        >
        > I have a problem with using YUI's JSON parser in Internet
        > Explorer(IE). I'm using IE, version 6. I'm able to use the parse
        > method just fine in Firefox(By the way, I'm using YUI 2.5.1).
        > However, when I try to use the JSON parser inside IE, I get unhandled
        > exception errors. Any clues as to what could be causing this problem?
        > Thanks in advance.
        >
      • rhild
        Make sure your JSON doesn t have any extra commas at the end of a list of items, as this causes a problem in IE but not in FireFox. Look for something like the
        Message 3 of 18 , Apr 1 6:17 PM
        • 0 Attachment
          Make sure your JSON doesn't have any extra commas at the end of a list
          of items, as this causes a problem in IE but not in FireFox.

          Look for something like the last comma here:
          {"name1": "1value", "name2": "value2", }

          -Ray

          --- In ydn-javascript@yahoogroups.com, "mr_cebyrd" <mr_cebyrd@...> wrote:
          >
          > I have a problem with using YUI's JSON parser in Internet
          > Explorer(IE). I'm using IE, version 6. I'm able to use the parse
          > method just fine in Firefox(By the way, I'm using YUI 2.5.1).
          > However, when I try to use the JSON parser inside IE, I get unhandled
          > exception errors. Any clues as to what could be causing this problem?
          > Thanks in advance.
          >
        • rhild
          Make sure your JSON doesn t have any extra commas at the end of a list of items, as this will cause an error in IE but not in Firefox. Look for something like
          Message 4 of 18 , Apr 1 6:24 PM
          • 0 Attachment
            Make sure your JSON doesn't have any extra commas at the end of a list
            of items, as this will cause an error in IE but not in Firefox.

            Look for something like this last comma:
            {"name1": "value1", "name2": "value2",}

            -Ray

            --- In ydn-javascript@yahoogroups.com, "mr_cebyrd" <mr_cebyrd@...> wrote:
            >
            > I have a problem with using YUI's JSON parser in Internet
            > Explorer(IE). I'm using IE, version 6. I'm able to use the parse
            > method just fine in Firefox(By the way, I'm using YUI 2.5.1).
            > However, when I try to use the JSON parser inside IE, I get unhandled
            > exception errors. Any clues as to what could be causing this problem?
            > Thanks in advance.
            >
          • mr_cebyrd
            It looks ok. At first, I thought it was a name-pair nesting problem. Here s a basic format of how I have it set up
            Message 5 of 18 , Apr 1 7:43 PM
            • 0 Attachment
              It looks ok. At first, I thought it was a name-pair nesting problem.
              Here's a basic format of how I have it set up

              {"dataentry"{"username":"foobar","attrib_1":"attrib_val","html_snippet":"actual
              html code here"}

              Basically what I did was to create an XML document on the server side.
              The actual Html was generated via an XSLT stylesheet which I had
              created on the fly (stored in the database). So I included the actual
              JSON string inside of the XML, using CDATA on it. Once it's back on
              the client-side, I got it set up to extract the JSON string using
              regular expressions. Once I get the JSON string, I run the JSON parser
              and put the HTML snippet inside of a div using innerHTML.

              So, in regard to your response, the JSON string doesn't seem to have
              any errant commas. So thinking along the line that you stated, I set
              up the YUI responseText to just display a simple string being returned
              from the server (i,e. YOOHOO). Same negative results, nothing shows
              up. Works ok for Firefox, not for IE. So I'm stumped for now. Any help
              that you can give would be greatly appreciated.

              Thanks




              --- In ydn-javascript@yahoogroups.com, "rhild" <rhild@...> wrote:
              >
              > Make sure your JSON doesn't have any extra commas at the end of a list
              > of items, as this causes a problem in IE but not in FireFox.
              >
              > Look for something like the last comma here:
              > {"name1": "1value", "name2": "value2", }
              >
              > -Ray
              >
              > --- In ydn-javascript@yahoogroups.com, "mr_cebyrd" <mr_cebyrd@> wrote:
              > >
              > > I have a problem with using YUI's JSON parser in Internet
              > > Explorer(IE). I'm using IE, version 6. I'm able to use the parse
              > > method just fine in Firefox(By the way, I'm using YUI 2.5.1).
              > > However, when I try to use the JSON parser inside IE, I get unhandled
              > > exception errors. Any clues as to what could be causing this problem?
              > > Thanks in advance.
              > >
              >
            • mr_cebyrd
              It looks ok. At first, I thought it was a name-pair nesting problem. Here s a basic format of how I have it set up
              Message 6 of 18 , Apr 1 7:46 PM
              • 0 Attachment
                It looks ok. At first, I thought it was a name-pair nesting problem.
                Here's a basic format of how I have it set up

                {"dataentry"{"username":"foobar","attrib_1":"attrib_val","html_snippet":"actual
                html code here"}

                Basically what I did was to create an XML document on the server side.
                The actual Html was generated via an XSLT stylesheet which I had
                created on the fly (stored in the database). So I included the actual
                JSON string inside of the XML, using CDATA on it. Once it's back on
                the client-side, I got it set up to extract the JSON string using
                regular expressions. Once I get the JSON string, I run the JSON parser
                and put the HTML snippet inside of a div using innerHTML.

                So, in regard to your response, the JSON string doesn't seem to have
                any errant commas. So thinking along the line that you stated, I set
                up the YUI responseText to just display a simple string being returned
                from the server (i,e. YOOHOO). Same negative results, nothing shows
                up. Works ok for Firefox, not for IE. So I'm stumped for now. Any help
                that you can give would be greatly appreciated.

                Thanks









                --- In ydn-javascript@yahoogroups.com, "y_lsmith" <lsmith@...> wrote:
                >
                > Do you have a sample page I could look at?
                >
                > Luke
                >
                >
                > --- In ydn-javascript@yahoogroups.com, "mr_cebyrd" <mr_cebyrd@> wrote:
                > >
                > > I have a problem with using YUI's JSON parser in Internet
                > > Explorer(IE). I'm using IE, version 6. I'm able to use the parse
                > > method just fine in Firefox(By the way, I'm using YUI 2.5.1).
                > > However, when I try to use the JSON parser inside IE, I get unhandled
                > > exception errors. Any clues as to what could be causing this problem?
                > > Thanks in advance.
                > >
                >
              • rhild
                How about posting your actual JSON string. The edited one below has two problems: no : after dataentry and it s missing a curly brace. -Ray ...
                Message 7 of 18 , Apr 2 3:39 AM
                • 0 Attachment
                  How about posting your actual JSON string. The edited one below has
                  two problems: no ':' after "dataentry" and it's missing a curly brace.

                  -Ray

                  --- In ydn-javascript@yahoogroups.com, "mr_cebyrd" <mr_cebyrd@...> wrote:
                  >
                  > It looks ok. At first, I thought it was a name-pair nesting problem.
                  > Here's a basic format of how I have it set up
                  >
                  >
                  {"dataentry"{"username":"foobar","attrib_1":"attrib_val","html_snippet":"actual
                  > html code here"}
                  >
                  >
                • umeshawasthi_80
                  Hi All, i am sending JSON data from my server for parsing it using YUI but i am facing the parsing failure music and i am clue less where is the error is there
                  Message 8 of 18 , Oct 22, 2008
                  • 0 Attachment
                    Hi All,

                    i am sending JSON data from my server for parsing it using YUI but i
                    am facing the parsing failure music and i am clue less where is the
                    error is there error in the JSON format i m sending from the server or
                    doing some thing wrong while parsing the data below i am pastig the
                    code for parsing the data using YUI along with the data which i am
                    getting from the server.

                    JSON Data i am getting from the server
                    {"firstName":"aum","lastName":"test","tinNumber":"123456"}

                    i made some changes to this and after this it is in the below mentioed
                    format

                    JSON DATA
                    [{"firstName":"aum","lastName":"test","tinNumber":"123456"}]

                    my JSOn parsing code

                    when it reached at this line messages =
                    "YAHOO.lang.JSON.parse(response);" i used to get parsing error

                    <script type="text/javascript">
                    YAHOO.util.Event.on('demo_btn','click',function (e) {
                    // Get the div element in which to report messages from the server
                    var msg_section = YAHOO.util.Dom.get('demo_msg');
                    msg_section.innerHTML = '';

                    // Define the callbacks for the asyncRequest
                    var callbacks = {

                    success : function (o) {
                    alert(o.responseText);
                    YAHOO.log("RAW JSON DATA: " + o.responseText);

                    var response=o.responseText;
                    msg_section.innerHTML = response;
                    response="["+response+"]";
                    alert(response);
                    //msg_section.innerHTML = response;
                    // Process the JSON data returned from the server
                    var messages = [];
                    try {
                    messages = YAHOO.lang.JSON.parse(response);
                    alert(message);
                    }
                    catch (x) {
                    alert("JSON Parse failed!");
                    return;
                    }

                    YAHOO.log("PARSED DATA: " + YAHOO.lang.dump(messages));

                    // The returned data was parsed into an array of objects.
                    // Add a P element for each received message
                    for (var i = 0, len = messages.length; i < len; ++i) {
                    var m = messages[i];
                    var p = document.createElement('p');
                    var message_text = document.createTextNode(
                    m.animal + ' says "' + m.message + '"');
                    p.appendChild(message_text);
                    msg_section.appendChild(p);
                    }
                    },

                    failure : function (o) {
                    if (!YAHOO.util.Connect.isCallInProgress(o)) {
                    alert("Async call failed!");
                    }
                    },

                    timeout : 3000
                    }

                    // Make the call to the server for JSON data
                    YAHOO.util.Connect.asyncRequest('GET',"YUIJSONTest.action",
                    callbacks);
                    });
                    </script>

                    any suggestion in this regard will be much appriciated.

                    Thanks
                    umesh
                  • umeshawasthi_80
                    Do any one have any idea about the below mentioed problems???? Plaes help in this regard
                    Message 9 of 18 , Oct 23, 2008
                    • 0 Attachment
                      Do any one have any idea about the below mentioed problems????

                      Plaes help in this regard

                      --- In ydn-javascript@yahoogroups.com, "umeshawasthi_80"
                      <umeshawasthi_80@...> wrote:
                      >
                      > Hi All,
                      >
                      > i am sending JSON data from my server for parsing it using YUI but i
                      > am facing the parsing failure music and i am clue less where is the
                      > error is there error in the JSON format i m sending from the server or
                      > doing some thing wrong while parsing the data below i am pastig the
                      > code for parsing the data using YUI along with the data which i am
                      > getting from the server.
                      >
                      > JSON Data i am getting from the server
                      > {"firstName":"aum","lastName":"test","tinNumber":"123456"}
                      >
                      > i made some changes to this and after this it is in the below mentioed
                      > format
                      >
                      > JSON DATA
                      > [{"firstName":"aum","lastName":"test","tinNumber":"123456"}]
                      >
                      > my JSOn parsing code
                      >
                      > when it reached at this line messages =
                      > "YAHOO.lang.JSON.parse(response);" i used to get parsing error
                      >
                      > <script type="text/javascript">
                      > YAHOO.util.Event.on('demo_btn','click',function (e) {
                      > // Get the div element in which to report messages from the server
                      > var msg_section = YAHOO.util.Dom.get('demo_msg');
                      > msg_section.innerHTML = '';
                      >
                      > // Define the callbacks for the asyncRequest
                      > var callbacks = {
                      >
                      > success : function (o) {
                      > alert(o.responseText);
                      > YAHOO.log("RAW JSON DATA: " + o.responseText);
                      >
                      > var response=o.responseText;
                      > msg_section.innerHTML = response;
                      > response="["+response+"]";
                      > alert(response);
                      > //msg_section.innerHTML = response;
                      > // Process the JSON data returned from the server
                      > var messages = [];
                      > try {
                      > messages = YAHOO.lang.JSON.parse(response);
                      > alert(message);
                      > }
                      > catch (x) {
                      > alert("JSON Parse failed!");
                      > return;
                      > }
                      >
                      > YAHOO.log("PARSED DATA: " + YAHOO.lang.dump(messages));
                      >
                      > // The returned data was parsed into an array of objects.
                      > // Add a P element for each received message
                      > for (var i = 0, len = messages.length; i < len; ++i) {
                      > var m = messages[i];
                      > var p = document.createElement('p');
                      > var message_text = document.createTextNode(
                      > m.animal + ' says "' + m.message + '"');
                      > p.appendChild(message_text);
                      > msg_section.appendChild(p);
                      > }
                      > },
                      >
                      > failure : function (o) {
                      > if (!YAHOO.util.Connect.isCallInProgress(o)) {
                      > alert("Async call failed!");
                      > }
                      > },
                      >
                      > timeout : 3000
                      > }
                      >
                      > // Make the call to the server for JSON data
                      > YAHOO.util.Connect.asyncRequest('GET',"YUIJSONTest.action",
                      > callbacks);
                      > });
                      > </script>
                      >
                      > any suggestion in this regard will be much appriciated.
                      >
                      > Thanks
                      > umesh
                      >
                    • Lucas Smith
                      ... umesh, Use the Console tab in the FireBug extension of Firefox to view the literal response text from the xhr call. You shouldn t need to wrap the
                      Message 10 of 18 , Oct 23, 2008
                      • 0 Attachment
                        --- In ydn-javascript@yahoogroups.com, "umeshawasthi_80"
                        <umeshawasthi_80@...> wrote:
                        >
                        > Hi All,
                        >
                        > i am sending JSON data from my server for parsing it using YUI but i
                        > am facing the parsing failure music and i am clue less where is the
                        > error is there error in the JSON format i m sending from the server or
                        > doing some thing wrong while parsing the data below i am pastig the
                        > code for parsing the data using YUI along with the data which i am
                        > getting from the server.
                        >
                        > JSON Data i am getting from the server
                        > {"firstName":"aum","lastName":"test","tinNumber":"123456"}
                        >
                        > i made some changes to this and after this it is in the below mentioed
                        > format
                        >
                        > JSON DATA
                        > [{"firstName":"aum","lastName":"test","tinNumber":"123456"}]
                        >
                        > my JSOn parsing code
                        >
                        > when it reached at this line messages =
                        > "YAHOO.lang.JSON.parse(response);" i used to get parsing error
                        >
                        > <script type="text/javascript">
                        > YAHOO.util.Event.on('demo_btn','click',function (e) {
                        > // Get the div element in which to report messages from the server
                        > var msg_section = YAHOO.util.Dom.get('demo_msg');
                        > msg_section.innerHTML = '';
                        >
                        > // Define the callbacks for the asyncRequest
                        > var callbacks = {
                        >
                        > success : function (o) {
                        > alert(o.responseText);
                        > YAHOO.log("RAW JSON DATA: " + o.responseText);
                        >
                        > var response=o.responseText;
                        > msg_section.innerHTML = response;
                        > response="["+response+"]";
                        > alert(response);
                        > //msg_section.innerHTML = response;
                        > // Process the JSON data returned from the server
                        > var messages = [];
                        > try {
                        > messages = YAHOO.lang.JSON.parse(response);
                        > alert(message);
                        > }
                        > catch (x) {
                        > alert("JSON Parse failed!");
                        > return;
                        > }
                        >
                        > YAHOO.log("PARSED DATA: " + YAHOO.lang.dump(messages));
                        >
                        > // The returned data was parsed into an array of objects.
                        > // Add a P element for each received message
                        > for (var i = 0, len = messages.length; i < len; ++i) {
                        > var m = messages[i];
                        > var p = document.createElement('p');
                        > var message_text = document.createTextNode(
                        > m.animal + ' says "' + m.message + '"');
                        > p.appendChild(message_text);
                        > msg_section.appendChild(p);
                        > }
                        > },
                        >
                        > failure : function (o) {
                        > if (!YAHOO.util.Connect.isCallInProgress(o)) {
                        > alert("Async call failed!");
                        > }
                        > },
                        >
                        > timeout : 3000
                        > }
                        >
                        > // Make the call to the server for JSON data
                        > YAHOO.util.Connect.asyncRequest('GET',"YUIJSONTest.action",
                        > callbacks);
                        > });
                        > </script>
                        >
                        > any suggestion in this regard will be much appriciated.
                        >
                        > Thanks
                        > umesh
                        >

                        umesh,

                        Use the Console tab in the FireBug extension of Firefox to view the
                        literal response text from the xhr call. You shouldn't need to wrap
                        the responseText in [ ], and there's nothing wrong with your code, so
                        far as I can tell. Clearly the error is in the format of the JSON data.

                        Use this tool to test the validity of your JSON string
                        http://chris.photobooks.com/json/default.htm

                        and reference http://json.org to review JSON syntax requirements.

                        If you are unable to determine where the syntax error is, post a url
                        to a page illustrating the problem and we'll have a look.

                        Hope this helps,
                        Luke
                      • Brian McCullough
                        ... Umesh and Lucas, As Satyam told us a few days ago, the problem is definitely in the format of the JSON data, which needs an outer variable to define the
                        Message 11 of 18 , Oct 23, 2008
                        • 0 Attachment
                          On Thu, Oct 23, 2008 at 03:30:13PM -0000, Lucas Smith wrote:
                          > --- In ydn-javascript@yahoogroups.com, "umeshawasthi_80"
                          > <umeshawasthi_80@...> wrote:
                          > >
                          > > JSON Data i am getting from the server
                          > > {"firstName":"aum","lastName":"test","tinNumber":"123456"}
                          > >
                          > > i made some changes to this and after this it is in the below mentioed
                          > > format
                          > >
                          > > JSON DATA
                          > > [{"firstName":"aum","lastName":"test","tinNumber":"123456"}]
                          >
                          > umesh,
                          >
                          > Use the Console tab in the FireBug extension of Firefox to view the
                          > literal response text from the xhr call. You shouldn't need to wrap
                          > the responseText in [ ], and there's nothing wrong with your code, so
                          > far as I can tell. Clearly the error is in the format of the JSON data.

                          Umesh and Lucas,

                          As Satyam told us a few days ago, the problem is definitely in the
                          format of the JSON data, which needs an "outer" variable to define the
                          array.

                          So for the example given, the JSON data should look like:


                          {"record":{"firstName":"aum","lastName":"test","tinNumber":"123456"}}



                          Brian
                        • Satyam
                          ... No, the one I reported is a problem with DataSource, not with JSON. He is using the plain YUI JSON utility and it can read and parse any sort of valid
                          Message 12 of 18 , Oct 23, 2008
                          • 0 Attachment
                            Brian McCullough wrote:
                            > On Thu, Oct 23, 2008 at 03:30:13PM -0000, Lucas Smith wrote:
                            >
                            >> --- In ydn-javascript@yahoogroups.com, "umeshawasthi_80"
                            >> <umeshawasthi_80@...> wrote:
                            >>
                            >>> JSON Data i am getting from the server
                            >>> {"firstName":"aum","lastName":"test","tinNumber":"123456"}
                            >>>
                            >>> i made some changes to this and after this it is in the below mentioed
                            >>> format
                            >>>
                            >>> JSON DATA
                            >>> [{"firstName":"aum","lastName":"test","tinNumber":"123456"}]
                            >>>
                            >> umesh,
                            >>
                            >> Use the Console tab in the FireBug extension of Firefox to view the
                            >> literal response text from the xhr call. You shouldn't need to wrap
                            >> the responseText in [ ], and there's nothing wrong with your code, so
                            >> far as I can tell. Clearly the error is in the format of the JSON data.
                            >>
                            >
                            > Umesh and Lucas,
                            >
                            > As Satyam told us a few days ago, the problem is definitely in the
                            > format of the JSON data, which needs an "outer" variable to define the
                            > array.
                            >
                            > So for the example given, the JSON data should look like:
                            >
                            >
                            > {"record":{"firstName":"aum","lastName":"test","tinNumber":"123456"}}
                            >
                            >
                            >
                            > Brian
                            >
                            >
                            >
                            No, the one I reported is a problem with DataSource, not with JSON. He
                            is using the plain YUI JSON utility and it can read and parse any sort
                            of valid JSON.

                            Satyam
                          • umeshawasthi_80
                            Hi Luke, Thanks for the information.i followed the steps suggested by you and check the JSON data validity which i am getting from the server. i checked the
                            Message 13 of 18 , Oct 23, 2008
                            • 0 Attachment
                              Hi Luke,

                              Thanks for the information.i followed the steps suggested by you and
                              check the JSON data validity which i am getting from the server.

                              i checked the validity of the incoming data from the link provided
                              by you and it validated the data successfully.

                              but still the problem is same. Since i am learning the YUI and
                              performing all the example on my local machine so it is not possible
                              for me post the link of the page and if there i some other way to do
                              this please let me know so that i can follow that steps, Till now i
                              am clue less about the problem what exactly is the case of parsing
                              failure....


                              thanks
                              umesh


                              --- In ydn-javascript@yahoogroups.com, "Lucas Smith" <lsmith@...>
                              wrote:
                              >
                              > --- In ydn-javascript@yahoogroups.com, "umeshawasthi_80"
                              > <umeshawasthi_80@> wrote:
                              > >
                              > > Hi All,
                              > >
                              > > i am sending JSON data from my server for parsing it using YUI
                              but i
                              > > am facing the parsing failure music and i am clue less where is
                              the
                              > > error is there error in the JSON format i m sending from the
                              server or
                              > > doing some thing wrong while parsing the data below i am pastig
                              the
                              > > code for parsing the data using YUI along with the data which i
                              am
                              > > getting from the server.
                              > >
                              > > JSON Data i am getting from the server
                              > > {"firstName":"aum","lastName":"test","tinNumber":"123456"}
                              > >
                              > > i made some changes to this and after this it is in the below
                              mentioed
                              > > format
                              > >
                              > > JSON DATA
                              > > [{"firstName":"aum","lastName":"test","tinNumber":"123456"}]
                              > >
                              > > my JSOn parsing code
                              > >
                              > > when it reached at this line messages =
                              > > "YAHOO.lang.JSON.parse(response);" i used to get parsing error
                              > >
                              > > <script type="text/javascript">
                              > > YAHOO.util.Event.on('demo_btn','click',function (e) {
                              > > // Get the div element in which to report messages from the
                              server
                              > > var msg_section = YAHOO.util.Dom.get('demo_msg');
                              > > msg_section.innerHTML = '';
                              > >
                              > > // Define the callbacks for the asyncRequest
                              > > var callbacks = {
                              > >
                              > > success : function (o) {
                              > > alert(o.responseText);
                              > > YAHOO.log("RAW JSON DATA: " + o.responseText);
                              > >
                              > > var response=o.responseText;
                              > > msg_section.innerHTML = response;
                              > > response="["+response+"]";
                              > > alert(response);
                              > > //msg_section.innerHTML = response;
                              > > // Process the JSON data returned from the server
                              > > var messages = [];
                              > > try {
                              > > messages = YAHOO.lang.JSON.parse(response);
                              > > alert(message);
                              > > }
                              > > catch (x) {
                              > > alert("JSON Parse failed!");
                              > > return;
                              > > }
                              > >
                              > > YAHOO.log("PARSED DATA: " + YAHOO.lang.dump
                              (messages));
                              > >
                              > > // The returned data was parsed into an array of
                              objects.
                              > > // Add a P element for each received message
                              > > for (var i = 0, len = messages.length; i < len; ++i)
                              {
                              > > var m = messages[i];
                              > > var p = document.createElement('p');
                              > > var message_text = document.createTextNode(
                              > > m.animal + ' says "' + m.message + '"');
                              > > p.appendChild(message_text);
                              > > msg_section.appendChild(p);
                              > > }
                              > > },
                              > >
                              > > failure : function (o) {
                              > > if (!YAHOO.util.Connect.isCallInProgress(o)) {
                              > > alert("Async call failed!");
                              > > }
                              > > },
                              > >
                              > > timeout : 3000
                              > > }
                              > >
                              > > // Make the call to the server for JSON data
                              > > YAHOO.util.Connect.asyncRequest('GET',"YUIJSONTest.action",
                              > > callbacks);
                              > > });
                              > > </script>
                              > >
                              > > any suggestion in this regard will be much appriciated.
                              > >
                              > > Thanks
                              > > umesh
                              > >
                              >
                              > umesh,
                              >
                              > Use the Console tab in the FireBug extension of Firefox to view the
                              > literal response text from the xhr call. You shouldn't need to
                              wrap
                              > the responseText in [ ], and there's nothing wrong with your code,
                              so
                              > far as I can tell. Clearly the error is in the format of the JSON
                              data.
                              >
                              > Use this tool to test the validity of your JSON string
                              > http://chris.photobooks.com/json/default.htm
                              >
                              > and reference http://json.org to review JSON syntax requirements.
                              >
                              > If you are unable to determine where the syntax error is, post a
                              url
                              > to a page illustrating the problem and we'll have a look.
                              >
                              > Hope this helps,
                              > Luke
                              >
                            • Brian McCullough
                              ... Sorry. I mis-remembered. Brian
                              Message 14 of 18 , Oct 23, 2008
                              • 0 Attachment
                                On Thu, Oct 23, 2008 at 06:30:45PM +0200, Satyam wrote:
                                >
                                > No, the one I reported is a problem with DataSource, not with JSON. He
                                > is using the plain YUI JSON utility and it can read and parse any sort
                                > of valid JSON.


                                Sorry. I mis-remembered.



                                Brian
                              • Lucas Smith
                                ... Umesh, I just noted something in your pasted code that is either a copy/paste typo or (if you re really (un)lucky, the root of your problem: [snip] ...
                                Message 15 of 18 , Oct 24, 2008
                                • 0 Attachment
                                  --- In ydn-javascript@yahoogroups.com, "umeshawasthi_80"
                                  <umeshawasthi_80@...> wrote:
                                  >
                                  > Hi Luke,
                                  >
                                  > Thanks for the information.i followed the steps suggested by you and
                                  > check the JSON data validity which i am getting from the server.
                                  >
                                  > i checked the validity of the incoming data from the link provided
                                  > by you and it validated the data successfully.
                                  >
                                  > but still the problem is same. Since i am learning the YUI and
                                  > performing all the example on my local machine so it is not possible
                                  > for me post the link of the page and if there i some other way to do
                                  > this please let me know so that i can follow that steps, Till now i
                                  > am clue less about the problem what exactly is the case of parsing
                                  > failure....
                                  >
                                  >
                                  > thanks
                                  > umesh
                                  >
                                  >

                                  Umesh,

                                  I just noted something in your pasted code that is either a copy/paste
                                  typo or (if you're really (un)lucky, the root of your problem:

                                  [snip]
                                  > > > var messages = [];
                                  > > > try {
                                  > > > messages = YAHOO.lang.JSON.parse(response);
                                  > > > alert(message);
                                  > > > }
                                  > > > catch (x) {
                                  > > > alert("JSON Parse failed!");
                                  > > > return;
                                  > > > }
                                  [snip]

                                  the variable message (singular) is not defined, so the alert line
                                  would throw an exception. You probably mean alert(messages);

                                  If that wasn't it, paste the entirety of the JSON data returned from
                                  your server into a paste service such as http://pastie.org and post
                                  the link here. You also might be able to get help in the #yui IRC
                                  channel on freenode.net

                                  Luke
                                • umeshawasthi_80
                                  Hi Luke, Thanks for the analyzig the code so deeply.. i think i have done the most silliest thing in my whole carrer ... yes that was the cause of the whole
                                  Message 16 of 18 , Oct 27, 2008
                                  • 0 Attachment
                                    Hi Luke,

                                    Thanks for the analyzig the code so deeply..

                                    i think i have done the most silliest thing in my whole carrer

                                    :)

                                    yes that was the cause of the whole problem and now i am able to
                                    parse the JSON data

                                    once again thanks foryour valuable help

                                    --umesh

                                    --- In ydn-javascript@yahoogroups.com, "Lucas Smith" <lsmith@...>
                                    wrote:
                                    >
                                    > --- In ydn-javascript@yahoogroups.com, "umeshawasthi_80"
                                    > <umeshawasthi_80@> wrote:
                                    > >
                                    > > Hi Luke,
                                    > >
                                    > > Thanks for the information.i followed the steps suggested by you
                                    and
                                    > > check the JSON data validity which i am getting from the server.
                                    > >
                                    > > i checked the validity of the incoming data from the link
                                    provided
                                    > > by you and it validated the data successfully.
                                    > >
                                    > > but still the problem is same. Since i am learning the YUI and
                                    > > performing all the example on my local machine so it is not
                                    possible
                                    > > for me post the link of the page and if there i some other way
                                    to do
                                    > > this please let me know so that i can follow that steps, Till
                                    now i
                                    > > am clue less about the problem what exactly is the case of
                                    parsing
                                    > > failure....
                                    > >
                                    > >
                                    > > thanks
                                    > > umesh
                                    > >
                                    > >
                                    >
                                    > Umesh,
                                    >
                                    > I just noted something in your pasted code that is either a
                                    copy/paste
                                    > typo or (if you're really (un)lucky, the root of your problem:
                                    >
                                    > [snip]
                                    > > > > var messages = [];
                                    > > > > try {
                                    > > > > messages = YAHOO.lang.JSON.parse(response);
                                    > > > > alert(message);
                                    > > > > }
                                    > > > > catch (x) {
                                    > > > > alert("JSON Parse failed!");
                                    > > > > return;
                                    > > > > }
                                    > [snip]
                                    >
                                    > the variable message (singular) is not defined, so the alert line
                                    > would throw an exception. You probably mean alert(messages);
                                    >
                                    > If that wasn't it, paste the entirety of the JSON data returned
                                    from
                                    > your server into a paste service such as http://pastie.org and post
                                    > the link here. You also might be able to get help in the #yui IRC
                                    > channel on freenode.net
                                    >
                                    > Luke
                                    >
                                  • umeshawasthi_80
                                    HI All, i am using YUI JSON utility for parsing JSON data i am getting from server here is the sanp shot of the data i am getting from server
                                    Message 17 of 18 , Feb 21, 2009
                                    • 0 Attachment
                                      HI All,

                                      i am using YUI JSON utility for parsing JSON data i am getting from server
                                      here is the sanp shot of the data i am getting from server

                                      [{"city":"Amdabad","country":"IN","cstNumber":"","faxNumber":"","firstName":"dgfdfgdfg","lastName":"gfhdfghf","mobile":"0","postalCode":"786876","region":"19","strSuppl1":"j","street":"j","telephoneNumber":"5678578678","tinNumber":"321","titleKey":"0001","userRole":"Admin"}]
                                      i even validated this JSON data and it has been validated successfully.
                                      here is the code i am using for parsing JSOn data using YUI

                                      <script type="text/javascript">
                                      YAHOO.util.Event.on('searchCustomerforDelete','click',function (e) {

                                      var selectedValue = dojo.widget.byId('tinNumber');
                                      var value1 = selectedValue.textInputNode.value;
                                      alert(value1);
                                      // Define the callbacks for the asyncRequest
                                      var callbacks = {

                                      success : function (o) {
                                      //YAHOO.log("RAW JSON DATA: " + o.responseText);
                                      var mess=o.responseText;
                                      // Process the JSON data returned from the server
                                      var messages = [];
                                      try {
                                      alert(mess);
                                      messages = YAHOO.lang.JSON.parse(mess);

                                      }
                                      catch (x) {
                                      alert(x);
                                      alert("JSON Parse failed!");
                                      return;
                                      }

                                      YAHOO.log("PARSED DATA: " + YAHOO.lang.dump(messages));

                                      // The returned data was parsed into an array of objects.
                                      // Add a P element for each received message
                                      for (var i = 0, len = messages.length; i < len; ++i) {

                                      }
                                      },

                                      failure : function (o) {
                                      if (!YAHOO.util.Connect.isCallInProgress(o)) {
                                      alert("Async call failed!");
                                      }
                                      },

                                      timeout : 3000
                                      }

                                      // Make the call to the server for JSON data
                                      var URL="SearchCustomerForDelete.action?tinNumber=";
                                      URL=URL+value1;
                                      alert(URL);
                                      YAHOO.util.Connect.asyncRequest('GET',URL, callbacks);
                                      });
                                      </script>

                                      but it i sgiving me following error
                                      Yahoo.lang.JSON has no property i am unable to figure it out where is
                                      the error can any one help me in pointing out the cause.

                                      Thanks in advance,
                                      umesh
                                    • Adam Moore
                                      ... You probably do not have the JSON utility included on the page. You can use the following tool to get a sorted list of required includes:
                                      Message 18 of 18 , Feb 21, 2009
                                      • 0 Attachment
                                        On Sat, Feb 21, 2009 at 02:45:42PM -0000, umeshawasthi_80 wrote:
                                        > but it i sgiving me following error
                                        > Yahoo.lang.JSON has no property i am unable to figure it out where is
                                        > the error can any one help me in pointing out the cause.

                                        You probably do not have the JSON utility included on the page. You can
                                        use the following tool to get a sorted list of required includes:

                                        http://developer.yahoo.com/yui/articles/hosting/#configure

                                        -Adam
                                      Your message has been successfully submitted and would be delivered to recipients shortly.