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.
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.
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)
jObject1.Merge(jObject2)
Dim mergedJson As String = jObject1.ToString()
hope it helps! Cheers
I already have 2 working JObjects.
jObject1.Merge(jObject2)
This was already mentioned in another thread and it doesn’t work, it shows this error.
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.
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
Cheers
“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
Cheers
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.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.