Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 05-08-2023 11:44 AM
i'm trying to split the array values to seperate list of object values but not able to get it.
input:
{
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiGeneraliDocumento": {
"TipoDocumento": "TD01",
"Numero": "126561",
"Data": "05.05.2023",
"Divisa": "EUR",
"ImportoTotaleDocumento": "9382.29"
},
"DatiDDT": {
"NumeroDDT": "086708,086704,086705,086706,086707"
}
}
}
}
using spec:
[
{
"operation": "shift",
"spec": {
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiDDT": {
"*": {
"NumeroDDT": "FatturaElettronicaBody.DatiGenerali.DatiDDT[&1].NumeroDDT"
}
}
}
}
}
}
]
but getting result as null.
expected output:
{
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiGeneraliDocumento": {
"TipoDocumento": "TD01",
"Numero": "126561",
"Data": "05.05.2023",
"Divisa": "EUR",
"ImportoTotaleDocumento": "9382.29"
},
"DatiDDT": {
"NumeroDDT":{
"086708
},
"NumeroDDT":{
086704
},
"NumeroDDT":{
086705
},
"NumeroDDT":{
086706
},
"NumeroDDT":{
086707"
}
}
}
}
}
Regards,
Pradeep
Created 05-08-2023 12:48 PM
Hi,
I believe this spec would help with setting the date as default date in each array element:
[
{
"operation": "modify-overwrite-beta",
"spec": {
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiDDT": {
"NumeroDDT": "=split('[,]',@(1,NumeroDDT))"
}
}
}
}
},
{
"operation": "shift",
"spec": {
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiGeneraliDocumento": "FatturaElettronicaBody.DatiGenerali.&",
"DatiDDT": {
"NumeroDDT": {
"*": {
"@": "FatturaElettronicaBody.DatiGenerali.DatiDDT[&1].NumeroDDT",
"@(3,DatiGeneraliDocumento.Data)": "FatturaElettronicaBody.DatiGenerali.DatiDDT[&1].Date"
}
}
}
}
}
}
}
]If that helps please accept solution.
Created 05-08-2023 11:45 AM
@SAMSAL , Could you please help on this
Created 05-08-2023 12:48 PM
Hi,
I believe this spec would help with setting the date as default date in each array element:
[
{
"operation": "modify-overwrite-beta",
"spec": {
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiDDT": {
"NumeroDDT": "=split('[,]',@(1,NumeroDDT))"
}
}
}
}
},
{
"operation": "shift",
"spec": {
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiGeneraliDocumento": "FatturaElettronicaBody.DatiGenerali.&",
"DatiDDT": {
"NumeroDDT": {
"*": {
"@": "FatturaElettronicaBody.DatiGenerali.DatiDDT[&1].NumeroDDT",
"@(3,DatiGeneraliDocumento.Data)": "FatturaElettronicaBody.DatiGenerali.DatiDDT[&1].Date"
}
}
}
}
}
}
}
]If that helps please accept solution.
Created 05-08-2023 12:52 PM
thank you so much for the quick help @SAMSAL .
Created 05-17-2023 11:31 AM
in Addition to above logic , if the input payload comes as below with number and Date combined in single array field.
input:
{
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiGeneraliDocumento": {
"TipoDocumento": "TD01",
"Numero": "126587",
"Data": "16.05.2023",
"Divisa": "EUR",
"ImportoTotaleDocumento": "7011.10"
},
"DatiDDT": [
{
"NumeroDDT": "126681-15.05.2023"
},
{
"NumeroDDT": "12680-10.05.2023"
}
]
}
}
}
Used the spec below:
[
{
"operation": "modify-overwrite-beta",
"spec": {
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiDDT": {
"*": {
"b_NumeroDDT": "=split('[-.]',@(1,NumeroDDT))",
"NumeroDDT": "@(1,b_NumeroDDT[0])",
"DataDDT": "=concat(@(1,b_NumeroDDT[3]),'-',@(1,b_NumeroDDT[2]),'-',@(1,b_NumeroDDT[1]))"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"FatturaElettronicaBody": {
"DatiGenerali": {
"DatiGeneraliDocumento": "FatturaElettronicaBody.DatiGenerali.&",
"DatiDDT": {
"*": {
"NumeroDDT": "FatturaElettronicaBody.DatiGenerali.DatiDDT[&1].NumeroDDT",
"DataDDT": "FatturaElettronicaBody.DatiGenerali.DatiDDT[&1].Date"
}
}
}
}
}
}
]
Output:
{
"FatturaElettronicaBody" : {
"DatiGenerali" : {
"DatiGeneraliDocumento" : {
"TipoDocumento" : "TD01",
"Numero" : "126587",
"Data" : "16.05.2023",
"Divisa" : "EUR",
"ImportoTotaleDocumento" : "7011.10"
},
"DatiDDT" : [ {
"NumeroDDT" : "126681",
"Date" : "2023-05-15"
}, {
"NumeroDDT" : "12680",
"Date" : "2023-05-10"
} ]
}
}
}