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

How to parse JSON data with DataSource

Expand Messages
  • Mike K.
    I have a simple PHP script that outputs the following JSON data: { ResultSet :{ Matrix : [{ jurisdictionId :1, classId :1, rate : 6.00 },
    Message 1 of 7 , Sep 29, 2008
    • 0 Attachment
      I have a simple PHP script that outputs the following JSON data:

      {"ResultSet":{"Matrix":
      [{"jurisdictionId":1,"classId":1,"rate":"6.00"},
      {"jurisdictionId":1,"classId":2,"rate":"0.00"},
      {"jurisdictionId":1,"classId":7,"rate":"0.00"},
      {"jurisdictionId":1,"classId":21,"rate":"0.00"},
      {"jurisdictionId":1,"classId":22,"rate":"0.00"},
      {"jurisdictionId":1,"classId":23,"rate":"0.00"},
      {"jurisdictionId":2,"classId":1,"rate":"0.00"},
      {"jurisdictionId":2,"classId":2,"rate":"0.00"},
      {"jurisdictionId":2,"classId":7,"rate":"0.00"},
      {"jurisdictionId":2,"classId":21,"rate":"0.00"},
      {"jurisdictionId":2,"classId":22,"rate":"0.00"},
      {"jurisdictionId":2,"classId":23,"rate":"0.00"},
      {"jurisdictionId":3,"classId":1,"rate":"0.00"},
      {"jurisdictionId":3,"classId":2,"rate":"0.00"},
      {"jurisdictionId":3,"classId":7,"rate":"0.00"},
      {"jurisdictionId":3,"classId":21,"rate":"0.00"},
      {"jurisdictionId":3,"classId":22,"rate":"0.00"},
      {"jurisdictionId":3,"classId":23,"rate":"0.00"},
      {"jurisdictionId":19,"classId":1,"rate":"0.00"},
      {"jurisdictionId":19,"classId":2,"rate":"0.00"},
      {"jurisdictionId":19,"classId":7,"rate":"0.00"},
      {"jurisdictionId":19,"classId":21,"rate":"0.00"},
      {"jurisdictionId":19,"classId":22,"rate":"0.00"},
      {"jurisdictionId":19,"classId":23,"rate":"0.00"}]}}

      It's a simple lookup table, based on jurisdictionId and classId, find
      the correct rate.

      I need to pass this to a page, and create a javascript array or
      object which can be queried by javascript on the page (dynamically).

      I have the following code:

      var taxDS = new YAHOO.util.DataSource("/json/matrix.php?");
      myDS.responseType = YAHOO.util.DataSource.TYPE_JSON;
      myDS.responseSchema = { resultsList: "ResultSet.Matrix", fields:
      ["jurisdictionId", "classId", "rate"] };

      var oCallback = {
      success: function(request, response, payload) {
      // here, response.results is an array, all all elements are empty
      string. I expect them to be javascript Objects with the properties
      "jurisdictionId", "classId", and "rate"
      },
      failure: function(oRequest,oResponse,oPayload) { alert("bad");}
      }
      myDS.sendRequest("", oCallback);


      I'm having no luck in determining the correct responseSchema to
      define. Nothing I've tried seems to work. I thought the object of
      JSON was to be able to easily create a Javascript Object without
      having to do a ton of parsing.

      Any help is appreciated, thanks.
    • Satyam
      It would help if you use the same name for all, it is taxDS when you create it, it is myDS when you set the options. Also, since I see they are all numbers,
      Message 2 of 7 , Sep 29, 2008
      • 0 Attachment
        It would help if you use the same name for all, it is taxDS when you
        create it, it is myDS when you set the options.
        Also, since I see they are all numbers, you could use:

        taxDS.responseSchema.fields: [{key:"jurisdictionId",parser:YAHOO.util.DataSource.parseNumber}, {key: "classId",parser:YAHOO.util.DataSource.parseNumber}, {key:"rate",parser:YAHOO.util.DataSource.parseNumber}] };

        Satyam




        Mike K. wrote:
        > I have a simple PHP script that outputs the following JSON data:
        >
        > {"ResultSet":{"Matrix":
        > [{"jurisdictionId":1,"classId":1,"rate":"6.00"},
        > {"jurisdictionId":1,"classId":2,"rate":"0.00"},
        > {"jurisdictionId":1,"classId":7,"rate":"0.00"},
        > {"jurisdictionId":1,"classId":21,"rate":"0.00"},
        > {"jurisdictionId":1,"classId":22,"rate":"0.00"},
        > {"jurisdictionId":1,"classId":23,"rate":"0.00"},
        > {"jurisdictionId":2,"classId":1,"rate":"0.00"},
        > {"jurisdictionId":2,"classId":2,"rate":"0.00"},
        > {"jurisdictionId":2,"classId":7,"rate":"0.00"},
        > {"jurisdictionId":2,"classId":21,"rate":"0.00"},
        > {"jurisdictionId":2,"classId":22,"rate":"0.00"},
        > {"jurisdictionId":2,"classId":23,"rate":"0.00"},
        > {"jurisdictionId":3,"classId":1,"rate":"0.00"},
        > {"jurisdictionId":3,"classId":2,"rate":"0.00"},
        > {"jurisdictionId":3,"classId":7,"rate":"0.00"},
        > {"jurisdictionId":3,"classId":21,"rate":"0.00"},
        > {"jurisdictionId":3,"classId":22,"rate":"0.00"},
        > {"jurisdictionId":3,"classId":23,"rate":"0.00"},
        > {"jurisdictionId":19,"classId":1,"rate":"0.00"},
        > {"jurisdictionId":19,"classId":2,"rate":"0.00"},
        > {"jurisdictionId":19,"classId":7,"rate":"0.00"},
        > {"jurisdictionId":19,"classId":21,"rate":"0.00"},
        > {"jurisdictionId":19,"classId":22,"rate":"0.00"},
        > {"jurisdictionId":19,"classId":23,"rate":"0.00"}]}}
        >
        > It's a simple lookup table, based on jurisdictionId and classId, find
        > the correct rate.
        >
        > I need to pass this to a page, and create a javascript array or
        > object which can be queried by javascript on the page (dynamically).
        >
        > I have the following code:
        >
        > var taxDS = new YAHOO.util.DataSource("/json/matrix.php?");
        > myDS.responseType = YAHOO.util.DataSource.TYPE_JSON;
        > myDS.responseSchema = { resultsList: "ResultSet.Matrix", fields:
        > ["jurisdictionId", "classId", "rate"] };
        >
        > var oCallback = {
        > success: function(request, response, payload) {
        > // here, response.results is an array, all all elements are empty
        > string. I expect them to be javascript Objects with the properties
        > "jurisdictionId", "classId", and "rate"
        > },
        > failure: function(oRequest,oResponse,oPayload) { alert("bad");}
        > }
        > myDS.sendRequest("", oCallback);
        >
        >
        > I'm having no luck in determining the correct responseSchema to
        > define. Nothing I've tried seems to work. I thought the object of
        > JSON was to be able to easily create a Javascript Object without
        > having to do a ton of parsing.
        >
        > Any help is appreciated, thanks.
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        > ------------------------------------------------------------------------
        >
        >
        > No virus found in this incoming message.
        > Checked by AVG - http://www.avg.com
        > Version: 8.0.169 / Virus Database: 270.7.5/1697 - Release Date: 29/09/2008 7:40
        >
        >
      • Mike K.
        ... you ... [{key: jurisdictionId ,parser:YAHOO.util.DataSource.parseNumber}, {key: classId ,parser:YAHOO.util.DataSource.parseNumber},
        Message 3 of 7 , Sep 29, 2008
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
          >
          > It would help if you use the same name for all, it is taxDS when
          you
          > create it, it is myDS when you set the options.
          > Also, since I see they are all numbers, you could use:
          >
          > taxDS.responseSchema.fields:
          [{key:"jurisdictionId",parser:YAHOO.util.DataSource.parseNumber},
          {key: "classId",parser:YAHOO.util.DataSource.parseNumber},
          {key:"rate",parser:YAHOO.util.DataSource.parseNumber}] };
          >
          > Satyam

          Satyam,

          naming issue was a copy/paste error into this thread. My mistake.

          I tried what you said, and it gets me closer, but I'm getting the
          value of the array index for each record, and only that. I'm not
          getting an array of JS object, but an array of numeric values each
          representing an array index, but not value. Here's my code
          (unabridged):

          var taxDS = new YAHOO.util.DataSource("/json/tax_matrix.php?");
          taxDS.responseType = YAHOO.util.DataSource.TYPE_JSON;
          taxDS.responseSchema = { resultsList: "ResultSet.Matrix",
          fields: [ { key: "jurisdictionId",
          parser:YAHOO.util.DataSource.parseNumber },
          { key: "classId",
          parser:YAHOO.util.DataSource.parseNumber },
          { key: "rate",
          parser:YAHOO.util.DataSource.parseNumber } ] };

          var oCallback = {
          success: function(request, response, payload) {
          for (var rate in response.results) {
          alert(typeof rate);
          alert(rate);
          }
          },
          failure: function(oRequest,oResponse,oPayload) { alert("bad");}
          }
          taxDS.sendRequest("", oCallback);
        • Satyam
          I would assume that both alerts should give you object . I often find that, if you don t have Firebug to simply inspect the variables, using YAHOO.lang.dump()
          Message 4 of 7 , Sep 29, 2008
          • 0 Attachment
            I would assume that both alerts should give you "object".

            I often find that, if you don't have Firebug to simply inspect the
            variables, using YAHOO.lang.dump() is quite useful:

            http://developer.yahoo.com/yui/docs/YAHOO.lang.html#method_dump

            Anyway, if you did:

            alert(rate.jurisdictionId);

            you should get the values for all jurisdictions.

            And regarding to DataSource suitability for this kind of data, well, not much really, not in this case. You could simply use the Connection Manager asyncRequest and then the JSON utility parse method and you would be getting basically the same. The good thing about the DataSource utility is that it provides a standard interface to many types of data so that if it ever changes, you don't need to change the logic, a few properties and that's it.

            Satyam



            Mike K. wrote:
            > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
            >
            >> It would help if you use the same name for all, it is taxDS when
            >>
            > you
            >
            >> create it, it is myDS when you set the options.
            >> Also, since I see they are all numbers, you could use:
            >>
            >> taxDS.responseSchema.fields:
            >>
            > [{key:"jurisdictionId",parser:YAHOO.util.DataSource.parseNumber},
            > {key: "classId",parser:YAHOO.util.DataSource.parseNumber},
            > {key:"rate",parser:YAHOO.util.DataSource.parseNumber}] };
            >
            >> Satyam
            >>
            >
            > Satyam,
            >
            > naming issue was a copy/paste error into this thread. My mistake.
            >
            > I tried what you said, and it gets me closer, but I'm getting the
            > value of the array index for each record, and only that. I'm not
            > getting an array of JS object, but an array of numeric values each
            > representing an array index, but not value. Here's my code
            > (unabridged):
            >
            > var taxDS = new YAHOO.util.DataSource("/json/tax_matrix.php?");
            > taxDS.responseType = YAHOO.util.DataSource.TYPE_JSON;
            > taxDS.responseSchema = { resultsList: "ResultSet.Matrix",
            > fields: [ { key: "jurisdictionId",
            > parser:YAHOO.util.DataSource.parseNumber },
            > { key: "classId",
            > parser:YAHOO.util.DataSource.parseNumber },
            > { key: "rate",
            > parser:YAHOO.util.DataSource.parseNumber } ] };
            >
            > var oCallback = {
            > success: function(request, response, payload) {
            > for (var rate in response.results) {
            > alert(typeof rate);
            > alert(rate);
            > }
            > },
            > failure: function(oRequest,oResponse,oPayload) { alert("bad");}
            > }
            > taxDS.sendRequest("", oCallback);
            >
            >
            >
            > ------------------------------------
            >
            > Yahoo! Groups Links
            >
            >
            >
            > ------------------------------------------------------------------------
            >
            >
            > No virus found in this incoming message.
            > Checked by AVG - http://www.avg.com
            > Version: 8.0.169 / Virus Database: 270.7.5/1697 - Release Date: 29/09/2008 7:40
            >
            >
          • Mike K.
            Thanks for the tip re: YAHOO.lang.dump(). alert(YAHOO.lang.dump(rate.jurisdictionId)); returns undefined. I would expect that rate is a JS object with 3
            Message 5 of 7 , Sep 29, 2008
            • 0 Attachment
              Thanks for the tip re: YAHOO.lang.dump().

              alert(YAHOO.lang.dump(rate.jurisdictionId));

              returns undefined. I would expect that 'rate' is a JS object with 3
              properties, 'jurisdictionId', 'classId', and 'rate'. But it seems to
              be a number in itself (125 for the first record, I have 126 rows, so
              I assume the array values are coming out backwards and I would get 0
              last).

              Since I'm getting what seems to be the array index, I'm assuming that
              my responseSchema is incorrect.

              What's weird is that alert(YAHOO.lang.dump(response)) returns what I
              would expect, what seems like a collection of objects.

              --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
              >
              > I would assume that both alerts should give you "object".
              >
              > I often find that, if you don't have Firebug to simply inspect the
              > variables, using YAHOO.lang.dump() is quite useful:
              >
              > http://developer.yahoo.com/yui/docs/YAHOO.lang.html#method_dump
              >
              > Anyway, if you did:
              >
              > alert(rate.jurisdictionId);
              >
              > you should get the values for all jurisdictions.
              >
              > And regarding to DataSource suitability for this kind of data,
              well, not much really, not in this case. You could simply use the
              Connection Manager asyncRequest and then the JSON utility parse
              method and you would be getting basically the same. The good thing
              about the DataSource utility is that it provides a standard interface
              to many types of data so that if it ever changes, you don't need to
              change the logic, a few properties and that's it.
              >
              > Satyam
              >
              >
              >
              > Mike K. wrote:
              > > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@> wrote:
              > >
              > >> It would help if you use the same name for all, it is taxDS when
              > >>
              > > you
              > >
              > >> create it, it is myDS when you set the options.
              > >> Also, since I see they are all numbers, you could use:
              > >>
              > >> taxDS.responseSchema.fields:
              > >>
              > > [{key:"jurisdictionId",parser:YAHOO.util.DataSource.parseNumber},
              > > {key: "classId",parser:YAHOO.util.DataSource.parseNumber},
              > > {key:"rate",parser:YAHOO.util.DataSource.parseNumber}] };
              > >
              > >> Satyam
              > >>
              > >
              > > Satyam,
              > >
              > > naming issue was a copy/paste error into this thread. My mistake.
              > >
              > > I tried what you said, and it gets me closer, but I'm getting the
              > > value of the array index for each record, and only that. I'm not
              > > getting an array of JS object, but an array of numeric values
              each
              > > representing an array index, but not value. Here's my code
              > > (unabridged):
              > >
              > > var taxDS = new YAHOO.util.DataSource("/json/
              tax_matrix.php?");
              > > taxDS.responseType = YAHOO.util.DataSource.TYPE_JSON;
              > > taxDS.responseSchema = { resultsList: "ResultSet.Matrix",
              > > fields: [ { key: "jurisdictionId",
              > > parser:YAHOO.util.DataSource.parseNumber },
              > > { key: "classId",
              > > parser:YAHOO.util.DataSource.parseNumber },
              > > { key: "rate",
              > > parser:YAHOO.util.DataSource.parseNumber } ] };
              > >
              > > var oCallback = {
              > > success: function(request, response, payload) {
              > > for (var rate in response.results) {
              > > alert(typeof rate);
              > > alert(rate);
              > > }
              > > },
              > > failure: function(oRequest,oResponse,oPayload) { alert
              ("bad");}
              > > }
              > > taxDS.sendRequest("", oCallback);
              > >
              > >
              > >
              > > ------------------------------------
              > >
              > > Yahoo! Groups Links
              > >
              > >
              > >
              > >
              ------------------------------------------------------------------------
              > >
              > >
              > > No virus found in this incoming message.
              > > Checked by AVG - http://www.avg.com
              > > Version: 8.0.169 / Virus Database: 270.7.5/1697 - Release Date:
              29/09/2008 7:40
              > >
              > >
              >
            • Satyam
              That is correct, I often get confused about the for(... in ...), it loops through the keys (not the values) to the object and, being an array, it will provide
              Message 6 of 7 , Sep 29, 2008
              • 0 Attachment
                That is correct, I often get confused about the for(... in ...), it
                loops through the keys (not the values) to the object and, being an
                array, it will provide a numeric key.

                This is what you want:

                for (var rate in response.results) {
                alert(response.results[rate].jurisdictionId);
                }

                Though this is far better:

                for (var i = 0,r = response.results, l = r.length;i<l;i++) ) {
                alert(r[i].jurisdictionId);
                }

                Satyam


                Mike K. wrote:
                > Thanks for the tip re: YAHOO.lang.dump().
                >
                > alert(YAHOO.lang.dump(rate.jurisdictionId));
                >
                > returns undefined. I would expect that 'rate' is a JS object with 3
                > properties, 'jurisdictionId', 'classId', and 'rate'. But it seems to
                > be a number in itself (125 for the first record, I have 126 rows, so
                > I assume the array values are coming out backwards and I would get 0
                > last).
                >
                > Since I'm getting what seems to be the array index, I'm assuming that
                > my responseSchema is incorrect.
                >
                > What's weird is that alert(YAHOO.lang.dump(response)) returns what I
                > would expect, what seems like a collection of objects.
                >
                > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
                >
                >> I would assume that both alerts should give you "object".
                >>
                >> I often find that, if you don't have Firebug to simply inspect the
                >> variables, using YAHOO.lang.dump() is quite useful:
                >>
                >> http://developer.yahoo.com/yui/docs/YAHOO.lang.html#method_dump
                >>
                >> Anyway, if you did:
                >>
                >> alert(rate.jurisdictionId);
                >>
                >> you should get the values for all jurisdictions.
                >>
                >> And regarding to DataSource suitability for this kind of data,
                >>
                > well, not much really, not in this case. You could simply use the
                > Connection Manager asyncRequest and then the JSON utility parse
                > method and you would be getting basically the same. The good thing
                > about the DataSource utility is that it provides a standard interface
                > to many types of data so that if it ever changes, you don't need to
                > change the logic, a few properties and that's it.
                >
                >> Satyam
                >>
                >>
                >>
                >> Mike K. wrote:
                >>
                >>> --- In ydn-javascript@yahoogroups.com, Satyam <satyam@> wrote:
                >>>
                >>>
                >>>> It would help if you use the same name for all, it is taxDS when
                >>>>
                >>>>
                >>> you
                >>>
                >>>
                >>>> create it, it is myDS when you set the options.
                >>>> Also, since I see they are all numbers, you could use:
                >>>>
                >>>> taxDS.responseSchema.fields:
                >>>>
                >>>>
                >>> [{key:"jurisdictionId",parser:YAHOO.util.DataSource.parseNumber},
                >>> {key: "classId",parser:YAHOO.util.DataSource.parseNumber},
                >>> {key:"rate",parser:YAHOO.util.DataSource.parseNumber}] };
                >>>
                >>>
                >>>> Satyam
                >>>>
                >>>>
                >>> Satyam,
                >>>
                >>> naming issue was a copy/paste error into this thread. My mistake.
                >>>
                >>> I tried what you said, and it gets me closer, but I'm getting the
                >>> value of the array index for each record, and only that. I'm not
                >>> getting an array of JS object, but an array of numeric values
                >>>
                > each
                >
                >>> representing an array index, but not value. Here's my code
                >>> (unabridged):
                >>>
                >>> var taxDS = new YAHOO.util.DataSource("/json/
                >>>
                > tax_matrix.php?");
                >
                >>> taxDS.responseType = YAHOO.util.DataSource.TYPE_JSON;
                >>> taxDS.responseSchema = { resultsList: "ResultSet.Matrix",
                >>> fields: [ { key: "jurisdictionId",
                >>> parser:YAHOO.util.DataSource.parseNumber },
                >>> { key: "classId",
                >>> parser:YAHOO.util.DataSource.parseNumber },
                >>> { key: "rate",
                >>> parser:YAHOO.util.DataSource.parseNumber } ] };
                >>>
                >>> var oCallback = {
                >>> success: function(request, response, payload) {
                >>> for (var rate in response.results) {
                >>> alert(typeof rate);
                >>> alert(rate);
                >>> }
                >>> },
                >>> failure: function(oRequest,oResponse,oPayload) { alert
                >>>
                > ("bad");}
                >
                >>> }
                >>> taxDS.sendRequest("", oCallback);
                >>>
                >>>
                >>>
                >>> ------------------------------------
                >>>
                >>> Yahoo! Groups Links
                >>>
                >>>
                >>>
                >>>
                >>>
                > ------------------------------------------------------------------------
                >
                >>> No virus found in this incoming message.
                >>> Checked by AVG - http://www.avg.com
                >>> Version: 8.0.169 / Virus Database: 270.7.5/1697 - Release Date:
                >>>
                > 29/09/2008 7:40
                >
                >>>
                >
                >
                >
                > ------------------------------------
                >
                > Yahoo! Groups Links
                >
                >
                >
                > ------------------------------------------------------------------------
                >
                >
                > No virus found in this incoming message.
                > Checked by AVG - http://www.avg.com
                > Version: 8.0.169 / Virus Database: 270.7.5/1697 - Release Date: 29/09/2008 7:40
                >
                >
              • Mike K.
                Satyam, How silly of me. I was thinking in PHP terms. Thanks for your help! -Mike ... +) ) { ... 3 ... to ... so ... get 0 ... that ... what I ... the ...
                Message 7 of 7 , Sep 30, 2008
                • 0 Attachment
                  Satyam,

                  How silly of me. I was thinking in PHP terms. Thanks for your help!

                  -Mike

                  --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
                  >
                  > That is correct, I often get confused about the for(... in ...), it
                  > loops through the keys (not the values) to the object and, being an
                  > array, it will provide a numeric key.
                  >
                  > This is what you want:
                  >
                  > for (var rate in response.results) {
                  > alert(response.results[rate].jurisdictionId);
                  > }
                  >
                  > Though this is far better:
                  >
                  > for (var i = 0,r = response.results, l = r.length;i<l;i+
                  +) ) {
                  > alert(r[i].jurisdictionId);
                  > }
                  >
                  > Satyam
                  >
                  >
                  > Mike K. wrote:
                  > > Thanks for the tip re: YAHOO.lang.dump().
                  > >
                  > > alert(YAHOO.lang.dump(rate.jurisdictionId));
                  > >
                  > > returns undefined. I would expect that 'rate' is a JS object with
                  3
                  > > properties, 'jurisdictionId', 'classId', and 'rate'. But it seems
                  to
                  > > be a number in itself (125 for the first record, I have 126 rows,
                  so
                  > > I assume the array values are coming out backwards and I would
                  get 0
                  > > last).
                  > >
                  > > Since I'm getting what seems to be the array index, I'm assuming
                  that
                  > > my responseSchema is incorrect.
                  > >
                  > > What's weird is that alert(YAHOO.lang.dump(response)) returns
                  what I
                  > > would expect, what seems like a collection of objects.
                  > >
                  > > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@> wrote:
                  > >
                  > >> I would assume that both alerts should give you "object".
                  > >>
                  > >> I often find that, if you don't have Firebug to simply inspect
                  the
                  > >> variables, using YAHOO.lang.dump() is quite useful:
                  > >>
                  > >> http://developer.yahoo.com/yui/docs/YAHOO.lang.html#method_dump
                  > >>
                  > >> Anyway, if you did:
                  > >>
                  > >> alert(rate.jurisdictionId);
                  > >>
                  > >> you should get the values for all jurisdictions.
                  > >>
                  > >> And regarding to DataSource suitability for this kind of data,
                  > >>
                  > > well, not much really, not in this case. You could simply use the
                  > > Connection Manager asyncRequest and then the JSON utility parse
                  > > method and you would be getting basically the same. The good
                  thing
                  > > about the DataSource utility is that it provides a standard
                  interface
                  > > to many types of data so that if it ever changes, you don't need
                  to
                  > > change the logic, a few properties and that's it.
                  > >
                  > >> Satyam
                  > >>
                  > >>
                  > >>
                  > >> Mike K. wrote:
                  > >>
                  > >>> --- In ydn-javascript@yahoogroups.com, Satyam <satyam@> wrote:
                  > >>>
                  > >>>
                  > >>>> It would help if you use the same name for all, it is taxDS
                  when
                  > >>>>
                  > >>>>
                  > >>> you
                  > >>>
                  > >>>
                  > >>>> create it, it is myDS when you set the options.
                  > >>>> Also, since I see they are all numbers, you could use:
                  > >>>>
                  > >>>> taxDS.responseSchema.fields:
                  > >>>>
                  > >>>>
                  > >>>
                  [{key:"jurisdictionId",parser:YAHOO.util.DataSource.parseNumber},
                  > >>> {key: "classId",parser:YAHOO.util.DataSource.parseNumber},
                  > >>> {key:"rate",parser:YAHOO.util.DataSource.parseNumber}] };
                  > >>>
                  > >>>
                  > >>>> Satyam
                  > >>>>
                  > >>>>
                  > >>> Satyam,
                  > >>>
                  > >>> naming issue was a copy/paste error into this thread. My
                  mistake.
                  > >>>
                  > >>> I tried what you said, and it gets me closer, but I'm getting
                  the
                  > >>> value of the array index for each record, and only that. I'm
                  not
                  > >>> getting an array of JS object, but an array of numeric values
                  > >>>
                  > > each
                  > >
                  > >>> representing an array index, but not value. Here's my code
                  > >>> (unabridged):
                  > >>>
                  > >>> var taxDS = new YAHOO.util.DataSource("/json/
                  > >>>
                  > > tax_matrix.php?");
                  > >
                  > >>> taxDS.responseType = YAHOO.util.DataSource.TYPE_JSON;
                  > >>> taxDS.responseSchema = { resultsList: "ResultSet.Matrix",
                  > >>> fields: [ { key: "jurisdictionId",
                  > >>> parser:YAHOO.util.DataSource.parseNumber },
                  > >>> { key: "classId",
                  > >>> parser:YAHOO.util.DataSource.parseNumber },
                  > >>> { key: "rate",
                  > >>> parser:YAHOO.util.DataSource.parseNumber } ] };
                  > >>>
                  > >>> var oCallback = {
                  > >>> success: function(request, response, payload) {
                  > >>> for (var rate in response.results) {
                  > >>> alert(typeof rate);
                  > >>> alert(rate);
                  > >>> }
                  > >>> },
                  > >>> failure: function(oRequest,oResponse,oPayload) { alert
                  > >>>
                  > > ("bad");}
                  > >
                  > >>> }
                  > >>> taxDS.sendRequest("", oCallback);
                  > >>>
                  > >>>
                  > >>>
                  > >>> ------------------------------------
                  > >>>
                  > >>> Yahoo! Groups Links
                  > >>>
                  > >>>
                  > >>>
                  > >>>
                  > >>>
                  > >
                  ------------------------------------------------------------------------
                  > >
                  > >>> No virus found in this incoming message.
                  > >>> Checked by AVG - http://www.avg.com
                  > >>> Version: 8.0.169 / Virus Database: 270.7.5/1697 - Release Date:
                  > >>>
                  > > 29/09/2008 7:40
                  > >
                  > >>>
                  > >
                  > >
                  > >
                  > > ------------------------------------
                  > >
                  > > Yahoo! Groups Links
                  > >
                  > >
                  > >
                  > >
                  ------------------------------------------------------------------------
                  > >
                  > >
                  > > No virus found in this incoming message.
                  > > Checked by AVG - http://www.avg.com
                  > > Version: 8.0.169 / Virus Database: 270.7.5/1697 - Release Date:
                  29/09/2008 7:40
                  > >
                  > >
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.