How to Merge Two Json Object?

Anyone please help me to merge 2 JSON Objects!

Hi @Akhil_Jose1

Can you give a try with this expression

JSonObject1.union(JSonObject2).ToArray

Regards
Gokul

Check out this blog as well @Akhil_Jose1

Regards
Gokul

Hi Gokul,

I tried this way but some issues are coming, Union is not a member of “newtonsoft.json.linq.JObect”. Also can you confirm that Data type of array is JArray?

Thank You

HI @Akhil_Jose1 ,
can you provide the sample input and output for this

Previously we were using this invoke code activity for merging 2 json objects.

JObject1.Merge(JObject2, New JsonMergeSettings With {.MergeArrayHandling = MergeArrayHandling.Union})

but now this is throwing some error that’s why I’m looking for an alternate method for merging 2 JObjects.

ERROR: merge jobjects: no compiled code to run error bc30560: ‘jobject’ is ambiguous in the namespace ‘newtonsoft.json.linq’. at line 0 error bc30560: ‘jobject’ is ambiguous in the namespace ‘newtonsoft.json.linq’. at line 0 error bc30560: ‘jsonmergesettings’ is ambiguous in the namespace ‘newtonsoft.json.linq’. at line 1

Hi,

Can you share Arguments panel of the invokeCode activity?

The last error will be fixed by adding namespace as the following.

JObject1.Merge(JObject2, New Newtonsoft.Json.Linq.JsonMergeSettings With {.MergeArrayHandling = Newtonsoft.Json.Linq.MergeArrayHandling.Union})

Regards,

Hi,

Thanks. It seems no problem…
Can you also share screenshot of Dialog for browse .net type and set JObject in the textbox?
If there are 2 or more JObject type, it might be cause.

image

Regards,

image

Hi

Tried This

System Error : UiPath.System.Activities → No compiled code to run
error BC30560: ‘JObject’ is ambiguous in the namespace ‘Newtonsoft.Json.Linq’. At line 0
error BC30560: ‘JObject’ is ambiguous in the namespace ‘Newtonsoft.Json.Linq’. At line 0
error BC30560: ‘JsonMergeSettings’ is ambiguous in the namespace ‘Newtonsoft.Json.Linq’. At line 1

But not working.

Regards

Hi,

Can you share your project? It’s no problem if dummy.

Regards,

image

I think the package inside system.activities newtonsoft json is not active color is light blue. PFA screen shot

Got the solution for this issue,

There are two packages(Office 365 & System.Activities) in my project contains Newtonsoft.Json. But UiPath Automatically take the latest version from the available versions. But my project requires one specific version So I updated Both packages contains Newtonsoft.Json to the latest.

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