Different Datatypes with Table to Json

Hey,

I have a “new_value” column which contains different DataTypes, I want to convert the table including this column to a Json.
However, I have issues to get this column into the json as the Table to Json, doesnt support DataValue, if I cast them to strings they end up as strings in my Json which I don’t want

Hi there @tbtt,

do you mind creating example and sharing with us?

Br,
Ivan

Here is an example, the question is basically what to do between concatenate and Output Container, to have the ids in the output as well.

Thank you!

test_output.knwf (19.5 KB)

Hi there @tbtt,

how about Column Auto Type Cast node? Will turn Non-Native to String type column.

Br,
Ivan

But that would mean all ids in the result are strings, I would like them to be their respective original type

You have currently typed the id columns differently. (string, number, JSON).

I changed them all to JSON type (which might seem/look weird), but at the end, this allows to preserve the original type and content:

image

Put the modified workflow on my NodePit Space:

– Philipp

3 Likes

Hi @tbtt,

I see now you wrote that in your first post, sry. Except from @qqilihq approach maybe this one can help as well. After each JSON Path node apply Table to JSON and then concatenate followed by JSON Row Combiner node? If you have all data in one table (under assumption attached workflow is only example) then first split your data set into multiple data sets based on value type in new_value column.

Br,
Ivan

2 Likes

I was able to solve this by adding the Column with multiple Datatypes with a Json Transformer Node after the Table to Json

1 Like

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