merge two JSON objects into one

Hello everyone :smiley:
I need to merge two JSON objects before I want to do my upload to the API.
I found online that I have to use JSON Transfomer… is that node the best way to do this? If yes, can someone please provide me an example? I did my research on that topic but I was not able to find any examples so I can understand how to use JSON transfomer.
Example of my two JSON objects i have to merge:

  • JSON1
    {
    key1 : value1,
    key2 : value2
    }

  • JSON2
    {
    key1 : {
    key2 : {
    key3: value }
    }
    }

image

Thanks in advance :smiley:

Denis

Hi there @denajaha,

to my understanding JSON Transformer is one to use. And JSON3 should look like? Not a JSON/API expert :open_mouth:

Br,
Ivan

JSON3 should just look like this:
{
key1 : value1,
key2 : value2,
key3 : {
key4 : {
key5 : value
}
}
}

Hi @denajaha,

you have those JSONs in different tables or if in same in different columns?

Maybe if you could share some dummy example would be best. From String Manipulation in your example :wink:

Br,
Ivan

Hi @ipazin
I have my data in one table but it is in multiple columns.

In my String Manipulatrion node I am simply using join to get the my data into the shape which API can accept and it looks like this:

I can not use only “Table to JSON” because in that case String I just manipulated using String Manipulation Node looks very strange and it includes the backslash which I do not need at all and my API does not accept it. And it looks like this:
image
That is why I used for that String --> String to JSON and for the rest of the data I used Table to JSON Node.
And now I have to merge those two JSON objects into one and simply do the upload request.

I hope you understand my problem now a little bit better!
Thank you for your help!

Kind regards,
Denis

Hi @denajaha,

tnx for explanation. Think I do understand it a bit more but afraid not to full extent :sweat_smile:

If two JSON columns you want to merge are in same table then you should use JSON Column Combiner. Then if format is not proper you can use JSON Transformer.

Anyways I would try keeping data as strings and manipulating it in such a way that when Column Combiner is used all that I have to do is to apply String to JSON (or any other “… to JSON” node) and I have my desired format for API.

Br,
Ivan

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