NIHVIVO-2343 Create a JavaScript utility for parsing the output of the SparqlQueryAjaxController.
This commit is contained in:
parent
1235402646
commit
4a78b32b34
1 changed files with 22 additions and 0 deletions
22
webapp/web/js/sparqlUtils.js
Normal file
22
webapp/web/js/sparqlUtils.js
Normal 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;
|
||||
}
|
||||
};
|
||||
|
Loading…
Add table
Reference in a new issue