Join two JObjects into one JObject

Hi, I have red a few topics about this and none of them worked for me, so I’m asking it myself.
I’m trying to merge/join two JObjects into one. 2 jsons into one json. Anyone knows how to do that?.

Thank you.

1 Like
  1. First, make sure you have imported the Newtonsoft.Json library. If you haven’t already, you can do it by following these steps:
  • In UiPath Studio, go to Manage Packages.
  • Search for “Newtonsoft.Json” in the Official tab and click Install.
  • After installation, you should see the Newtonsoft.Json namespace available in your project.
  1. Use the following code to merge two JSON objects:

Imports Newtonsoft.Json.Linq

Dim json1 As String = “{ ““name””: ““John””, ““age””: 30 }”
Dim json2 As String = “{ ““city””: ““New York””, ““country””: ““USA”” }”

Dim jObject1 As JObject = JObject.Parse(json1)
Dim jObject2 As JObject = JObject.Parse(json2)


Dim mergedJson As String = jObject1.ToString()

hope it helps! Cheers


I already have 2 working JObjects.

I just want to merge them.

This was already mentioned in another thread and it doesn’t work, it shows this error.

1 Like

Hi @Axel_Albert

Check out this thread. It might help you solve the error.

Hope it helps!!

1 Like

I already checked that thread (and many others). It didn’t help.

1 Like

Not to be rude, but dude, I already tried the “jObject1.Merge(jObject2)”, you have the screenshot above.
It does not work. Don’t repeat the same, read and help, or don’t comment.

1 Like


The merge needs to be used in the invoke code and not in assign activity

Pass both the jobjects as in/out arguments to invoke code and then use it inside invoke code…it would work

Hope this helps


1 Like

“Invoke method” activity should work as well.

Thanks, it works now.

By the way. Do you know how to assign an Array(of String) to a JToken?
Now I’m stuck with that and I can’t find information.

I can assign one string of the array

But this is what happens when I try to assign the array


You mean you want to create a jarray?

If ao first you need to create the array using Jar.add("eachname") in a loop and then use new jobject(new jproperty("name",jar) where jar is of type jarray


Not a JArray, no. I was trying to assign an array of Strings into a Jtoken, but I was told you can’t do that.

So I joined the array of strings into a string, and assigned the string.

Thanks though.

1 Like

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