Version 4, last updated by slim at March 18, 2007 22:05 UTC

Yahoo has a standard format on their json return data, a little bit like google data. This is a generic blueprint which generates a more manageable output array for html inclusion.

Demos that use it

  • map.html
  • yahoosearch.html
  • multi_map.html

Yahoo's JSON RSS format


  {
    ResultSet: {
      totalResultsAvailable:string,
      totalResultsReturned:string,
      firstResultPosition:string,
      Result:[
        {Title:string,
	 Summary:string,
	 Url:string,
	 ClickUrl:string,
	 RefererUrl:string,
	 FileSize:string,
	 FileFormat:string,
	 Height:string,
	 Width:string,
	 Thumbnail:{
	   Url:string,
	   Height:string,
	   Width:string
	 }
	}
      ]
    }
  }

BLUEPRINT(
"~0108660CEBFAB14d9e8D69AB83384B9B0C",
[
 ["json_rss_in", "onJsonRss", 10]
],
[
 "textscrap_collection_out"
],
function (Class) 
{

    Class.prototype.onJsonRss = function(msg)
    {
	var coll = [];	
	var n, result, results;

	try {
	  n = parseInt(msg.ResultSet.totalResultsReturned);
	} catch (ex) {
	  this.error(ex, "malformed JSON RSS output");

	  return;
	  /*****************************************************************/
	}

	if (n == 1) {
	  results = [msg.ResultSet.Result];
	} else {
	  results = msg.ResultSet.Result;
	}

	for (i = 0; i < n; i++) {
	    result = results[i];

	    coll.push({name:result.Title,
		       text_content:result.Summary,
		       uri:result.Url,
			  latitude: parseFloat(result.Latitude),
			  longitude: parseFloat(result.Longitude),
			  street: result.Address,
		      locality: result.City,
			  region: result.State,
			  telephone_number:result.Phone})
	}

	this.postMessage("textscrap_collection_out", coll);
    };

}, "JSON RSS to Collection");