Table to JSON with Arrays

Hi all!

Time for me to again turn to the KNIME collective mind with a JSON question. I want to send a table to data to an API and it takes a JSON input with an array. I cannot figure out how to in KNIME easily create JSON Arrays.

For example, I have a two column table, id and text, I want to turn the table to a JSON output but the API is expecting all of this data to be wrapped up into an array named documents.

Here’s the output I require;

“text”:“Hello world”
“text”:“Bonjour tout le monde”
“text”:“The food was cold when it arrived it was disgusting”

I can’t figure out the array part. Thank you as always!

1 Like

Hi @craigcullum -

Here’s one way to do it:

JSON_Array_Wrap_Example.knwf (10.6 KB)

I adapted the workflow from this forum thread, which contains a more complicated example: Optimal way to convert Table to JSON

Hope it helps!

That’s perfect! Thanks so much Scott.

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