How to concatenate json or string outputs from two nodes

Hi,
I want to produce a single JSON file with two key-value pairs.

I have two database views which I have used in ‘DB Query Reader’ nodes and then I am converting two outputs to two different Json using ‘Table to Json’ node. Now I want to concatenate these two Json as two key-value pairs in one Json output. I tried using string manipulation node (basically to give names to key-value pair) but stuck at a step to concatenate two ouputs in one output. Please help.

Here is the output I am looking for:

{
  "elements": [
    {"label": "A"},
    {"label": "B"},
    {"label": "C"}
  ],
  "connections": [
    {"from": "A", "to": "B"}
    {"from": "A", "to": "C"}
  ]
}

The data for “elements” and “connections” key-value pairs come from two separate views.

This is how my current workflow looks:
image

Why not merging the tables before?

Because:

  1. There are different sets of columns in the outputs of two views
  2. In final Json each view output data is stored in two separate key value pairs named as elements and connections. Please refer sample output json.

Adding one more sample of Json just to clarify how columns can vary in elements and connections:

{
elements”: [
{
“Label” : “Company1”,
“Type” : “Type A”,
“Leadership” : “Person1, VP, Department1|Person2, CEO, Department2…”,
“Website” : “www.company1.com
}, {
“Label” : “Company2”,
“Type” : “TypeB”,
“Description” : “Company2 description”,
“Website” : “www.Company2.com
}, {
“Label” : “Company3”,
“Type” : “TypeB”,
“Description” : “Company3 description”,
“Website” : “www.Company3.com
}
],
connections”: [
{
“From” : “Company1”,
“To” : “Company2”,
“Type” : “Contractual”,
“Description” : “Connection1 description.”
}, {
“From” : “Company2”,
“To” : “Company3”,
“Type” : “Contractual”,
“Description” : “Connection2 description”
}
]
}

Did you’ve searched for JSON Column combine?

There are also a variate of other transformation nodes available. Though, JSON, which is my personell opinion, is kind of a dead end. XML with XSLT transformation or much more convenient table transformation are way more straight forward and flexible.

Kind regards
Mike

1 Like

The solution you have provided uses two columns from same table. I have two columns coming from two nodes and I am looking for solution to append the outputs of two nodes.

Unfortunately I dont have option to use xml. It has to be Json output.

Hi there @ddnyaneshwar,

Then use Column Appender node to have it in one table?

Br,
Ivan

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