Appending two jobjects into one

Hi I wanted to merge two Jobjects into 1

initial Jobject:
{
“GUID”: “e080fdc6-20e2-4661-bb45-df27fb58d619”,
“ClientInfo”: {
“DelphiScore”: “999”,
“DocumentKey”: “76149c73-45de-477c-bc27-0a8f2f6ad46b”,
“DocumentUrl”: “Test document via API.pdf”
}

the second jobejct: {
“InsuredCompaniesInfo”: [
{
“InsuredCompanyId”: 138,
“CompanyInfo”: {
“DelphiScore”: “123”,
“DocumentKey”: “76149c73-45de-477c-bc27-0a8f2f6ad46b”,
“DocumentUrl”: “Test document via API.pdf”
}
},
{
“InsuredCompanyId”: 139,
“CompanyInfo”: {
“DelphiScore”: “456”,
“DocumentKey”: “76149c73-45de-477c-bc27-0a8f2f6ad46b”,
“DocumentUrl”: “Test document via API.pdf”
}
}
]
}

the jobect id like to create once merged:

{
“GUID”: “e080fdc6-20e2-4661-bb45-df27fb58d619”,
“ClientInfo”: {
“DelphiScore”: “999”,
“DocumentKey”: “76149c73-45de-477c-bc27-0a8f2f6ad46b”,
“DocumentUrl”: “Test document via API.pdf”
},
“InsuredCompaniesInfo”: [
{
“InsuredCompanyId”: 138,
“CompanyInfo”: {
“DelphiScore”: “123”,
“DocumentKey”: “76149c73-45de-477c-bc27-0a8f2f6ad46b”,
“DocumentUrl”: “Test document via API.pdf”
}
},
{
“InsuredCompanyId”: 139,
“CompanyInfo”: {
“DelphiScore”: “456”,
“DocumentKey”: “76149c73-45de-477c-bc27-0a8f2f6ad46b”,
“DocumentUrl”: “Test document via API.pdf”
}
}
]
}

1 Like

can you check the description? At the first look the second JObject looks same as the expected output JObject

Thanks i have now corrected this

give a try at:
grafik

And set the parameters as described here in the docu:

@duaine.b

you can merge two JSON objects using in an Assign activity:

mergedJsonObject = JObject.FromObject(JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(jsonObject1)).Merge(JObject.FromObject(JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(jsonObject2)))

once try this
cheers…!

I’m receiving this error when I try

NewtonsoftIson.LingJObjecttoString:Option Strict On disallows implicit conversions from Newtonsoft.son.linqObject’to’String

The Merge Method from newtonsoft (link from above) is a so called void method. In VB.Net world a so called sub / subroutine and is not a function returning a value.

A BC30491 Expression does not produce a value will be raised.

Therefore we cannot use within an Assign Activity and Invoke Method was suggested

Above error is about datatype missmatch of a JObject and String
We will ignore the unneded conversions from JO to a serialized JSON to get it again Deserialized

  • myJO1.Merge(myJO2) it the same in short
  • myJO1.Merge(myJO2).ToString would haromize the DataType missmatches (JSON String returned)
  • But will not work as elaborated above: BC30491 issue

to elaborate more the above:

The simple one without additiona mergesetting configurations:

grafik

JO2 will be merged to JO1

1 Like

This is brillant, i really appreciate the support Peter!! I’ve been struggling with this for months now!

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