user484948
user484948

Reputation: 69

Read JSON using Jquery

I have created a JS file with the following contents;

{ "Root":{"APPLICATION":"TestMenu",
          "SUBROOT":["ADMIN","Seller","Buyer"]
       "TAB":"ADMIN":"Home","ADMIN":"LiveAuction","ADMIN":"Master","ADMIN":"PostAuction"]
                  "SUBTAB":[
                            {"APPLICATION":"TestMenu","SUBROOT":"ADMIN","TAB":"HOME","CHILD":"HOME","URL":"\Default.aspx"},
                                {"APPLICATION":"TestMenu","SUBROOT":"ADMIN","TAB":"LiveAuction","CHILD":"","URL":"#"},
                                {"APPLICATION":"TestMenu","SUBROOT":"ADMIN","TAB":"LiveAuction","CHILD":"AuctionCatalog","URL":"\AuctionCatalog.aspx"},
                                {"APPLICATION":"TestMenu","SUBROOT":"ADMIN","TAB":"LiveAuction","CHILD":"BidBook","URL":"\BidBook.aspx"},
                                {"APPLICATION":"TestMenu","SUBROOT":"ADMIN","TAB":"LiveAuction","CHILD":"SampleRequest","URL":"\SampleRequest.aspx"}
                           ]
           }
  }

I am calling that JS file with the following code;

  $.getJSON("js/TestMenu.js", {}, function (json) { JsonCallBack(json); });
    function JsonCallBack(json) {
        $.each(json.results, function (i, tweet) {
            alert("JSON Data: " + json.Root);
        });
    }

Now I want that JSON in single object which I can retrieve but I am not getting that JSON.

When I run firebug I can see that reponse is same. Can anyone tell me why this isn't working?

Upvotes: 1

Views: 692

Answers (1)

StevenLooman
StevenLooman

Reputation: 381

Your JSON is invalid. Use JSLint to check if your JSON is valid. JSLint says this: Error: Problem at line 1 character 74: Expected '}' to match '{' from line 1 and instead saw 'TAB'.

{ "Root":{"APPLICATION":"TestMenu", "SUBROOT":["ADMIN","Seller","Buyer"] "TAB...

Problem at line 1 character 79: Expected '}' to match '{' from line 1 and instead saw ':'.

{ "Root":{"APPLICATION":"TestMenu", "SUBROOT":["ADMIN","Seller","Buyer"] "TAB...

Problem at line 1 character 80: Expected '(end)' and instead saw 'ADMIN'.

{ "Root":{"APPLICATION":"TestMenu", "SUBROOT":["ADMIN","Seller","Buyer"] "TAB...

JSON: bad.

Upvotes: 1

Related Questions