Take the 2-minute tour ×

and thanks for reading.

I wrote a web service which is called through jsonp, and returns a .Net 3.5 DataSet which I then want to parse using jquery. It appears that the getJson() method is working fine as far as parsing the json goes. The following request -

            $.getJSON("http://localhost:80/ws.asmx/Example?format=json&callback=?", function(data) {

results in -

{"Tables": [


  "Rows": [


      "CASE_TYP_CD": "M",


      "AUTO_GENERATE": "Y",




      "CASE_TYP_CD": "T",


      "AUTO_GENERATE": "Y",




      "CASE_TYP_CD": "J",


      "AUTO_GENERATE": "Y",



Well I'm kind of new at this whole json thing and I can't figure out how to gain access to the values held in the nodes.

I was thinking it would be something like -

$.each("CASE_TYP_CD", function() { //code goes here });

But that doesn't seem to be working.

Could anyone help me out with this?

Thanks in advance!

share|improve this question
welcome to stackoverflow.com! –  dlamotte May 6 '10 at 22:54
As an aside, JSON has native boolean types - they'd might be a better match for your "CONFIDENTIAL_FLG" and "AUTO_GENERATE" fields if your only values are "Y" and "N"... –  Thanatos May 7 '10 at 1:22

5 Answers 5

Read this: http://api.jquery.com/jQuery.getJSON/

share|improve this answer
Thank you I already have been through that page. I must be missing something because if I try alert(data.CASE_TYP_CD[0]) I recieve a javascript error that CASE_TYP_CD.0 is undefined. –  Zachary Carter May 6 '10 at 22:58

You may want to read up on general JavaScript object literals (which are very similar to JSON).

What I see from JSON, to get the value of CASE_TYP_CD in the first row of the first table you write

var result = <json>;
var val result.Table[0].Rows[0].CASE_TYP_CD;

is that what you wanted to know?

share|improve this answer

here's how you would iterate through your object with $.each():

$.each(data.d.Tables, function(index, table) {
    $.each(table.Rows, function(index, row) {
share|improve this answer

I'm pretty sure something is up with the way the DataSet is being serialized in my web service.

Whenever I try a method, including the ones that have been suggested here I get two javascript errors -

Message: 'length' is null or not an object
Line: 29
Char: 452
Code: 0
URI: js/jquery-1.4.2.min.js


Message: Object doesn't support this property or method
Line: 1
Char: 1
Code: 0
URI: /GetCaseTypes?format=json&callback=jsonp1273246775675

Thank you for all your suggestions but it looks like my problem lies within the serialization of the DataSet and not in my jquery code.

share|improve this answer

I figured out the problem, apparently the getJson method wasn't actually parsing the json string into a java object like it should have been. I simply had to add

var obj = $.parseJSON(data.d);

and everything worked as expected.

Thanks to everyone who posted here.

share|improve this answer

Your Answer


