I’m trying to create a recursive JSON tree from a bunch of repeating rows as an input and can’t figure out how to do it. I would really appreciate some hints.
It’s basically just a table with defined paths:
Similiar to what the JSON Row combiner is doing, but each new row has to be nested in the row before it:
Something like this:
I feel like it should be really simple, I just don’t get how to approach this.
Thanks in advance, David.
did you try the “Collect into object with key” option of the JSON Row Combiner? From the description this looks similar to what you describe.
If you can share your table with us, this would also help to find a solution.
Hello @daniela_digles Thanks for the reply.
I gave up and asked a dev colleague to solve this in Python for me. But I would still really like to see a solution with the JSON transformer.
KNIME Nested JSON_Example Table.xlsx (9.8 KB)
KNIME Nested JSON_Target JSON.json (2.1 KB)
Would be greatly appreciated.
it didn’t work with the JSON Row Combiner, but the JSON Transformer worked. It is not yet an optimal solution (e.g. it would need either an automated creation of the path or an automatically created JSON Transformer statement), but as you already have a Python solution I didn’t want to spent too much time on this.
So here are two examples on how you can use the JSON Transformer (either a combination with the JSON Row Combiner and a move operator, or an add operator in a recursive loop). I’ve added some comments where additional work would be necessary to make this automatically.
Json_nested.knwf (72.1 KB)
@daniela_digles That is amazing work, thank you.
The loop solution is a clear winner in my book, that’s exactly what I wanted, just didn’t know how.
The main advantage here is that I kind of understand what it does, the Python solution… not quite yet, I’m working on it, step by step.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.