jhpoelen/eol-globi-js

[FEATURE] Introduce column name mapping api for type=json requests

Closed this issue · 1 comments

Resonse structure for "type=json" requests

{
  "columns": ["column_name_1", "column_name_two", "column_name_xyz"],
  "data" [
    ["cell 1", "cell2", "cell3"]
  ]  
}

Currently there is no code based mapping of the column position to the column name, so if one needs a specific column entry which is only known by name she has to count it out. This is error-prone and really inconvenient.

We need a small mapping api to fetch column entries by name independent of requested order.

F.x.:

var indexOfColumnFoo = response.getColumnIndexByName('foo');
var nameIndexedRow = response.getRow(position, INDEX_TYPE_NAME);

Fixed by 1134c29

Implementation is done as a wrapper which normalizes the access of data of both response types. (see example in commit message)

Demo http://www.globalbioticinteractions.org/browse/ was updated too.