• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

JSON parsing using javascript

Hello Sir,

Could you please help me to parse this Json response.

  How can I parse this JSON response using JavaScript for getting title, description, siteHost and Clickurl.

   "bossresponse": {
      "responsecode": "200",
           "ads": {
                "resultset": {
                    "id": "adListings",
                    "numResults": "1",
                        "listing": [
                                "rank": "1",
                                "title": "<b>Football</b> Equipment",
                                "description": "Large selection of <b>football</b> equipment and training aids",
                                "siteHost": "www.athleticsgalore.com",
                                "clickurl": "http://1010101.r.msn.com/?ld=4vq9ndR1Iz05F-VIR1ArZ-yMDKq78eT62kklvEWHpT7_2T6zwB-UELQxgdhrYum33ydEW48-CGl-yXCLedW3LQ6ApZNZ-6G6pc7fHVo5V50mLQhHj9lr533IlA8xzM8y9VMi7cd66LXkpWPv3nuBptDfzXd34S7fPTz4wcOxUHPODOMFjXA2p5Mzw5hhSTSdd7t7Af_RgCG1UFBtdTHJte9ctQWOxcw-nJ6FFS7v15FsqDxEJOslcVD9iH1pp52ZnxPBnkGBAmY3M9z-1RJIREEbcjGSDlX7HcXsiDZHm-FBRbIIaxnsN06bI"
1 Solution
I think this should work... (JSONRespText contains the response above)

var myObj = eval('(' + JSONRespText + ')');
var listings = myObj.bossresponse.ads.resultset.listing;
var rank = listings[0].rank;
var title = listings[0].title;
var desc = listings[0].description;
var siteHost = listings[0].siteHost;
var clickurl = listings[0].clickurl;

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now