Closed jasonclake closed 4 years ago
@jasonclake , Seems this problem is mentioned here -> https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/sqlp/rbafyjsonpublishing.htm
I do not know if the format json
clause described in the article resolve the problem?
:wave: Hi! This issue has been marked stale due to inactivity. If no further activity occurs, it will automatically be closed.
@jasonclake Since Db2 has no "JSON" type (the JSON publishing functions merely return a CLOB), there is no way within the existing driver framework to do this.
One possible solution would be to create some kind of flag to idb-connector to have it run JSON.parse on the output. Alternatively, a more general solution would be to allow users to add some sort of converter function to a column to have idb-connector call it before returning the results to the user. Something like:
let statement = new dbstmt(conn);
statement.output_converter(2, JSON.parse)
statement.exec(sql, (result, error) => { ... })
PyODBC has something similar, though it works on a type-by-type basis (which wouldn't work here, since again there's no JSON type) instead of a column-by-column basis.
Alternatively, you could continue to do the mapping yourself and make it as generic as needed.
Is there a way to tell idb-connector when some columns already contain JSON data? In other words, avoid javascript having to parse the JSON string after the fact.
For example: Let's say you have a table in your database with a list of document types where the actual document is stored as JSON in the INFO_JSON data column.
RECEIVED OUTPUT
DESIRED OUTPUT