Take the 2-minute tour ×

I am trying to grab some data via JSONP. Using Firebug, I am able to see the data properly being returned, but I am having a hard time thinking how I have to parse it. The data return is really a nested array correct? someFunction is the name of the callback function. This is how the data looks:

    "title":"Sample Title,  
    "description":"Sample Description",  
    "publisher":"Sample Publisher",  
    "creator":"Sample Author",  
    "date":"Thu, 19 Aug 2010 12:41:29 GMT",  

Just a little confused about how to properly parse and output.

share|improve this question
add comment

2 Answers

up vote 16 down vote accepted

You don't have to parse the data. It is already a valid JavaScript object. For instance, to print the description property for the first object inside someFunction

function someFunction(result) {
    alert(result[0].description); // alerts "Sample Description"
share|improve this answer
add comment

Write a function with the correct name and the correct arguments. The JS engine will do the parsing for you.

function someFunction(data) {
    // Now data is an Array, containing a single
    // Object with 8 properties (title, link, etc)
share|improve this answer
add comment

Your Answer


