NIHVIVO-2343 Create a JavaScript utility for parsing the output of the SparqlQueryAjaxController.

This commit is contained in:
j2blake 2011-10-27 14:35:54 +00:00
parent 1235402646
commit 4a78b32b34

View file

@ -0,0 +1,22 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
/*
* Parse the results that we got from the SparqlQueryAjaxController.
*
* The input is a complex structure from the controller. The output is an array
* of maps where each map represents a result row, populated with key-value pairs.
*/
sparqlUtils = {
parseSparqlResults: function(data) {
var parsed = [];
$.each(data.results.bindings, function() {
var row = {};
for (var i in this) {
row[i] = this[i].value;
}
parsed.push(row);
});
return parsed;
}
};