Basic JSON question: How to parse JSON?
I am new to JSON and trying to recover some text from a JSON variable.

The JSON variable is sent from a [Javascript File ][1]and has this structure:

`foo({  
  "query": {  
  "count": "2",  
  "created": "2009-07-25T08:17:54Z",  
  "lang": "en-US",    
  },  
  "results": {  
   "result": [  
    {  
     "abstract": "<b>Pizza</b> Hut®. Order Online for Delivery or Carry-out. Fast &amp; Easy.",  
     "title": "<b>Pizza</b> Hut"  
    },  
    {  
     "abstract": "Official site of Domino's <b>Pizza</b> delivery chain, which offers thin crust, deep dish, and hand tossed <b>pizzas</b> with a variety of side items and beverages. Site <b>...</b>",  
     "title": "Domino's <b>Pizza</b>"  
    }  
   ]  
  }
 }
});`


The JSON goes to a callback function named foo:

    function foo(o){
      var out = document.getElementById('container');
      out.innerHTML = o.query.count;
    }

**My Problem:** I know how to print out the query count variable using the callback function above, but I don't know how to print out the the title of the first result in the results array.

How can I change the callback function to display the first result title?
And also, is there a foreach statement, where I could print out all the titles from all the results?

Thanks!


  [1]: http://query.yahooapis.com/v1/public/yql?q=select%20title%2Cabstract%20from%20search.web%20where%20query%3D%22pizza%22%20LIMIT%202&format=json&callback=foo
Basic JSON question: How to parse JSON?
===

I am new to JSON and trying to recover some text from a JSON variable.

The JSON variable is sent from a [Javascript File ][1]and has this structure:

`foo({  
  "query": {  
  "count": "2",  
  "created": "2009-07-25T08:17:54Z",  
  "lang": "en-US",    
  },  
  "results": {  
   "result": [  
    {  
     "abstract": "<b>Pizza</b> Hut®. Order Online for Delivery or Carry-out. Fast &amp; Easy.",  
     "title": "<b>Pizza</b> Hut"  
    },  
    {  
     "abstract": "Official site of Domino's <b>Pizza</b> delivery chain, which offers thin crust, deep dish, and hand tossed <b>pizzas</b> with a variety of side items and beverages. Site <b>...</b>",  
     "title": "Domino's <b>Pizza</b>"  
    }  
   ]  
  }
 }
});`


The JSON goes to a callback function named foo:

    function foo(o){
      var out = document.getElementById('container');
      out.innerHTML = o.query.count;
    }

**My Problem:** I know how to print out the query count variable using the callback function above, but I don't know how to print out the the title of the first result in the results array.

How can I change the callback function to display the first result title?
And also, is there a foreach statement, where I could print out all the titles from all the results?

Thanks!


  [1]: http://query.yahooapis.com/v1/public/yql?q=select%20title%2Cabstract%20from%20search.web%20where%20query%3D%22pizza%22%20LIMIT%202&format=json&callback=foo