Solved

JSON parsing using javascript

Posted on 2012-03-14
1
259 Views
Last Modified: 2012-06-25
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"
                                }
                                   ]
                             }
                 }
    }
}
0
Comment
Question by:jacobbbc
1 Comment
 
LVL 7

Accepted Solution

by:
micropc1 earned 500 total points
Comment Utility
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

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now