Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

JOLT returns UNexpected array

avatar
Explorer

Here is my Input Json,

[
{
"PortfolioSharing": [],
"CustomFields": [
{
"PrimaryId": 2069165,
"ColumnName": "TRX_PORTFOLIO_CUSTOMFIELD2",
"FieldName": "Use Bank Account From Customer?",
"DataType": "nvarchar",
"Value": "Yes",
"HideFromExternalDistributor": 0,
"IsRequired": 0,
"ViewName": "UseBankAccountFromCustomer?",
"Type": "dropdown",
"Id": 103
}
],
"Id": 2069165,
"Guid": "0f2aa667-5d6d-4e8a-9ed1-7ef89db03d6d",
"Name": "N.M. SANGANI"
},
{
"PortfolioSharing": [
{
"PortfolioId": 2074065,
"CustomerId": 2159935,
"PersonalId": "1006631",
"ReasonId": 810,
"ReasonProgId": "OWNER",
"ReasonName": "Company owner",
"Comment": null,
"TypeId": 808,
"TypeProgId": "FULL",
"TypeName": "Full"
}
],
"CustomFields": [
{
"PrimaryId": 2074065,
"ColumnName": "TRX_PORTFOLIO_CUSTOMFIELD2",
"FieldName": "Use Bank Account From Customer?",
"DataType": "nvarchar",
"Value": "Yes",
"HideFromExternalDistributor": 0,
"IsRequired": 0,
"ViewName": "UseBankAccountFromCustomer?",
"Type": "dropdown",
"Id": 103
}
],
"Id": 2074065,
"Guid": "b276ec7e-b770-4dae-a9b7-2390652ec0d2",
"Name": "M. K. BANDARA & G. R. M. K.BANDARA(Jt)"
},
{
"PortfolioSharing": [
{
"PortfolioId": 2074396,
"CustomerId": 2160183,
"PersonalId": "1006833",
"ReasonId": 810,
"ReasonProgId": "OWNER",
"ReasonName": "Company owner",
"Comment": null,
"TypeId": 808,
"TypeProgId": "FULL",
"TypeName": "Full"
},
{
"PortfolioId": 2074396,
"CustomerId": 2160182,
"PersonalId": "1006832",
"ReasonId": 810,
"ReasonProgId": "OWNER",
"ReasonName": "Company owner",
"Comment": null,
"TypeId": 808,
"TypeProgId": "FULL",
"TypeName": "Full"
}
],
"CustomFields": [
{
"PrimaryId": 2074396,
"ColumnName": "TRX_PORTFOLIO_CUSTOMFIELD2",
"FieldName": "Use Bank Account From Customer?",
"DataType": "nvarchar",
"Value": "Yes",
"HideFromExternalDistributor": 0,
"IsRequired": 0,
"ViewName": "UseBankAccountFromCustomer?",
"Type": "dropdown",
"Id": 103
}
],
"Id": 2074396,
"Guid": "96a07682-8d94-4739-bae0-a950b58fffad",
"Name": "L.S.P. VIDANAGAMAGE"
}
]

==============================

And here is JOLT spec that I'm used,

[
{
"operation": "shift",
"spec": {
"*": {
"PortfolioSharing": {
"*": {
"*": "[&1].&"
}
}
}
}
}
]
===================================
And here is the OUPUT json,

[ {
"PortfolioId" : [ 2074065, 2074396 ],
"CustomerId" : [ 2159935, 2160183 ],
"PersonalId" : [ "1006631", "1006833" ],
"ReasonId" : [ 810, 810 ],
"ReasonProgId" : [ "OWNER", "OWNER" ],
"ReasonName" : [ "Company owner", "Company owner" ],
"Comment" : null,
"TypeId" : [ 808, 808 ],
"TypeProgId" : [ "FULL", "FULL" ],
"TypeName" : [ "Full", "Full" ]
}, {
"PortfolioId" : 2074396,
"CustomerId" : 2160182,
"PersonalId" : "1006832",
"ReasonId" : 810,
"ReasonProgId" : "OWNER",
"ReasonName" : "Company owner",
"Comment" : null,
"TypeId" : 808,
"TypeProgId" : "FULL",
"TypeName" : "Full"
} ]

But I need to get it like that,

[ {
"PortfolioId" : 2074065,
"CustomerId" : 2159935,
"PersonalId" : "1006631",
"ReasonId" : [ 810, 810 ,
"ReasonProgId" : "OWNER",
"ReasonName" : "Company owner",,
"Comment" : null,
"TypeId" : 808,
"TypeProgId" : "FULL",
"TypeName" : "FULL"
},{
"PortfolioId" : 2074396,
"CustomerId" : 2160183,
"PersonalId" : "1006833",
"ReasonId" : 810,
"ReasonProgId" : "OWNER",
"ReasonName" : "Company owner",
"Comment" : null,
"TypeId" : 808,
"TypeProgId" : "FULL",
"TypeName" : "Full"
}, {
"PortfolioId" : 2074396,
"CustomerId" : 2160182,
"PersonalId" : "1006832",
"ReasonId" : 810,
"ReasonProgId" : "OWNER",
"ReasonName" : "Company owner",
"Comment" : null,
"TypeId" : 808,
"TypeProgId" : "FULL",
"TypeName" : "Full"
} ]

I need to get each an objects in separately in same json array.
How should I change my spec?

Thanks

2 REPLIES 2

avatar
Explorer

Hi @Thar11027 , the spec here seems really simple:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "PortfolioSharing": {
          "*": "[]"
        }
      }
    }
  }
]

Tell me if you have any doubts

avatar
Expert Contributor

Hi @Thar11027 ,

Can you try something like this below.

saquibsk_0-1719488104808.png

Thanks,

Shakib M.