Table to JSON - to a predefined schema

I would like to output values from a table to a JSON data schema. At the moment, I have no control over the structure of the JSON except for adding specific values. I want to map from table to names in the data schema the same as I do when I read a JSON using JSON Path to map out the values I want to retrieve.

Is there a version of JSON Path which allows me to add a JSON as output and map to it from table? Additionally, I would like to add static values which do not come from the data values from the table.

Thanks, Matt

Hi Matt,

Table to JSON is quite opinionated, it was created to support common use cases, but it would be hard to support all use cases with this kind of dialog. So in case this does not fit your transformation requirements, you might need to pre- or postprocess the results. (There is some functionality that would enable the GroupBy, Column Aggregator functions that might be better fit other use cases, though those are not enabled currently.)

JSONPath can only map from JSON cells, so in case you want to combine the JSON from multiple JSON columns, you will need the JSON Transformer (after JSONPath if you only need parts from it) and use those columns.

You can select JSON from JSON using the JSON Path nodes, for example see (please apologize for the Result is List option checked, it should not be):

Adding static values is possible with the JSON Transformer node, from KNIME 3.2 even flow variables and column values are supported too as I remember. I think the Merge Patch option is more user-friendly unless you already have JSONPointers (which might be the case if you need to obey to certain JSON Schema).

Cheers, gabor

Thanks for your response. I am trying to use to e JSON Transformer but just cannot get my head around the language in order to make it work, it makes little sense to me. Thanks, Matt

Hi Matt,

I hope you will succeed. Just curious... Which language do you find hard to use JSON Patch or JSON Merge Patch? (Or the node description?)

Cheers, gabor