Solved

JSON parsing using javascript

Posted on 2012-03-14
1
263 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
ID: 37723443
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how can i test my code? 1 39
How to show span when clicked on? 10 22
Getting Random number with min and max value. 2 28
replace link with jQuery 4 14
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

809 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