- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
add outside value to array using jolt
- Labels:
-
Apache NiFi
Created on 10-10-2023 07:25 AM - edited 10-10-2023 08:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
Could you please help in getting below value to be splitted across the array , the value outside of arrray
Input:
{
"DatiRiepilogo": {
"Natura": "N3.5",
"AliquotaIVA": [
"22.00",
"5.00"
],
"ImponibileImporto": [
"215.43",
"6.70"
],
"Imposta": [
"47.39",
"0.34"
]
}
}
SPEC:
[
{
"operation": "shift",
"spec": {
"DatiRiepilogo": {
"Natura":{
"*":{
"@(2,Natura)": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].Natura"
}},
"AliquotaIVA": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].AliquotaIVA",
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].AliquotaIVA"
}
},
"ImponibileImporto": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].ImponibileImporto",
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].ImponibileImporto"
}
},
"Imposta": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].Imposta",
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].Imposta"
}
}
}
}
}
]
Expected Output:
{
"FatturaElettronicaBody" : {
"DatiBeniServizi" : {
"DatiRiepilogo" : [ {
"Natura": "N3.5",
"AliquotaIVA" : "22.00",
"ImponibileImporto" : "215.43",
"Imposta" : "47.39"
}, {
"Natura": "N3.5",
"AliquotaIVA" : "5.00",
"ImponibileImporto" : "6.70",
"Imposta" : "0.34"
} ]
}
}
}
Created 10-10-2023 10:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @PradNiFi1236 ,
Is the following spec what you are looking for:
[
{
"operation": "shift",
"spec": {
"DatiRiepilogo": {
"AliquotaIVA": {
"*": {
"@(2,Natura)": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].Natura",
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].AliquotaIVA"
}
},
"ImponibileImporto": {
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].ImponibileImporto"
}
},
"Imposta": {
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].Imposta"
}
}
}
}
}
]
Created 10-10-2023 10:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @PradNiFi1236 ,
Is the following spec what you are looking for:
[
{
"operation": "shift",
"spec": {
"DatiRiepilogo": {
"AliquotaIVA": {
"*": {
"@(2,Natura)": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].Natura",
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].AliquotaIVA"
}
},
"ImponibileImporto": {
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].ImponibileImporto"
}
},
"Imposta": {
"*": {
"@": "FatturaElettronicaBody.DatiBeniServizi.DatiRiepilogo[&1].Imposta"
}
}
}
}
}
]
Created 10-10-2023 11:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you So much @SAMSAL ,
if the input is array of values then its coming good, How about if input is nonarray value something like this
{
"DatiBeniServizi": {
"DatiRiepilogo": {
"AliquotaIVA": "22.00",
"ImponibileImporto": "367.94",
"Imposta": "80.95"
}
}
i think without [&1] will work but how to accept both nonarray and array input using single spec?
}
Created 10-10-2023 12:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I dont think you can use the same jolt spec for two different schema. Jolt spec doesnt allow you to use the same key multiple times. You have to know beforehand what schema are you getting then direct to different jolt transformation processor , or store the spec dynamically in an attribute to pass it to single jolt processor
