Nodedevelopment: Return a DataTableColumn with a JSON Cell

Hello,

currently I’am developing a node which returns a JSON String.

For now I return a Data Table which returns a column with StringCells. Now I want to extend this to a JSON Cell.

The method looks like in the following example:

private static DataTableSpec createSpec() {

  		DataTableSpecCreator table = new DataTableSpecCreator();  		

  		DataColumnSpecCreator column = new DataColumnSpecCreator("Result", new StringCell("").getType());
  		
  		table.addColumns(column.createSpec());
  		
  		return table.createSpec();
  	}

How can I change the cell from StringCell to a JsonCell?

Has someone any ideas?

Thank you!

Greetings
Egg

Hi @EggOfFitch,
first a general tip for KNIME development, instead of creating a cell to get access to it’s type:

You should use the static member that contains the type instead, in this caseStringCell.TYPE.

Now to answer your question, to create a JSONCell you need to add a dependency to org.knime.json to your plugin.xml as a required bundle:

Then you can create JSONCells using JSONCellFactory.create(String json, boolean allowComments).

best,
Gabriel

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.