Member since
07-29-2020
574
Posts
323
Kudos Received
176
Solutions
My Accepted Solutions
| Title | Views | Posted |
|---|---|---|
| 2157 | 12-20-2024 05:49 AM | |
| 2454 | 12-19-2024 08:33 PM | |
| 2203 | 12-19-2024 06:48 AM | |
| 1467 | 12-17-2024 12:56 PM | |
| 2112 | 12-16-2024 04:38 AM |
11-09-2023
07:09 AM
Hi @PradNiFi1236 , It seems in your spec when you do the "modify-overwrite-beta" it will create the object "AltriDatiGestionali" on each array element regardless of the Natura value and it doesnt seem that there is an easy way to remove the unwanted "AltriDatiGestionali" without over complicating the spec. However if you can change the order of how you do things in the spec you might be able to avoid this problem all together , so instead of doing the following: shift-1, shift-2, modify-overwrite-beta, remove, cardinality you can change the order as follows: shift-1, modify-overwrite-beta, remove, shift-2, cardinality So basically after you isolate the "AltriDatiGestionali" object in the first shift , then you do the modification over there, then you remove unwanted fields and finally you shift to the element where Natura = N3.5 and finish with the cardinality. I dont think the recursivelySquashNulls modify at the end is doing anything so you can remove it. Here is how the spec looks like: [
{
"operation": "shift",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
"AltriDatiGestionali": "FatturaElettronicaBody.DatiBeniServizi.AltriDatiGestionali",
"*": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].&"
}
}
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"AltriDatiGestionali": {
"splitRiferimentoTesto": "=split('-',@(1,RiferimentoTesto))",
"stringsize": "=size(@(1,splitRiferimentoTesto[0]))",
"RiferimentoTesto": "=substring(@(1,splitRiferimentoTesto[0]),26,@(1,stringsize))",
"stringsize1": "=size(@(1,splitRiferimentoTesto[1]))",
"RiferimentoD": "=substring(@(1,splitRiferimentoTesto[1]),11,@(1,stringsize1))",
"splitRiferimentoData": "=split('/',@(1,RiferimentoD))",
"RiferimentoData": "=concat(@(1,splitRiferimentoData[2]),'-',@(1,splitRiferimentoData[1]),'-',@(1,splitRiferimentoData[0]))"
}
}
}
}
}
,
{
"operation": "remove",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"AltriDatiGestionali": {
"splitRiferimentoTesto": "",
"splitRiferimentoData": "",
"stringsize": "",
"stringsize1": "",
"RiferimentoD": ""
}
}
}
}
}
,
{
"operation": "shift",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
"NumeroLinea": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].NumeroLinea",
"PrezzoTotale": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].PrezzoTotale",
"Descrizione": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].Descrizione",
"Natura": {
"N3.5": {
"$": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].Natura",
"@(2,NumeroLinea)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].NumeroLinea",
"@(2,PrezzoTotale)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].PrezzoTotale",
"@(2,Descrizione)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].Descrizione",
"@(4,AltriDatiGestionali)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].AltriDatiGestionali"
},
"*": {
"$": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].Natura",
"@(2,NumeroLinea)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].NumeroLinea",
"@(2,PrezzoTotale)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].PrezzoTotale",
"@(2,Descrizione)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].Descrizione"
}
}
}
}
}
}
}
}
,
{
"operation": "cardinality",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
"NumeroLinea": "ONE",
"Descrizione": "ONE",
"Quantita": "ONE",
"PrezzoUnitario": "ONE",
"ScontoMaggiorazione": "ONE",
"AltriDatiGestionali": "ONE",
"PrezzoTotale": "ONE",
"AliquotaIVA": "ONE"
}
}
}
}
}
}
] If that helps please accept solution. Thanks
... View more
11-09-2023
05:27 AM
Are you sure you are getting the correct input to the JoltTransformJSON processor? If you are able to test the spec using GenerateFlowFile and its working then something might be happening upstream that might be causing the input to change or dropped. I would check the EvaluateJsonPath Destination property and make sure its not set flowfile-content, rather it should be set to flowfile-attribute. If you think everything is set correctly, can you take screenshot of all processors configurations in your reply? Thanks
... View more
11-08-2023
01:14 PM
Hi @CE , Where exactly are you getting the null? are you getting it after the Jolt processor in the success relationship queue? I ran the same spec against simple GenerateFlowFile with the input you provided set in the CustomText property then use the Jolt processor with the provided spec and I got the expected output. Can you try that and see if it works? Can you also provide processor configuration screenshot ? Thanks
... View more
11-02-2023
11:27 AM
Can you send me the spec as it seems to be different from what I provided? Also if you can simplify the input\spec and keep it isolated to the problem that will save me sometime.
... View more
11-02-2023
06:33 AM
2 Kudos
To do the split , you need to transform the json input into a format that allows you to do so, for that you can use JoltTransformationJson with the following Jolt Specification: [
{
"operation": "modify-overwrite-beta",
"spec": {
"ids": "=split('[,]',@(1,id))"
}
},
{
"operation": "shift",
"spec": {
"ids": {
"*": {
"@": "[&1].id",
"@(2,Qid)": "[&1].Qid"
}
}
}
}
] The spec above will generate the following output: [
{
"id": "652fbf430f1f3f30a3111f11",
"Qid": 123
},
{
"id": "652fbf430f1f3f30a3333f11",
"Qid": 123
}
] Then you can use SplitJson processor where the JsonPath Expression is set to $ To get the id attribute you can use EvaluateJsonPath as follows: The flowfile_id is dynamic property where the value is the json path to the id of the json input. Make sure to set the Destination property to "flowfile-attribute". If that helps please accept solution. Thanks
... View more
10-31-2023
12:47 PM
1 Kudo
There is a lot to take here. It would be better if you always can simplify the problem by removing redundancy and isolating it where you can only re create the scenario you are trying to resolve. You dont have to use the exact data specially when its not worded in English as you can spend sometime trying to create a dummy data that resemble your structure which is easy to understand and readable by others. Keep in mind the more time you spend simplifying and articulating your problem the higher the chances it will get attention and the it will get resolved. Please keep that in mind when submitting other posts. As far as your problem goes, it was hard for me to follow everything but something that might be causing the issue is the spec for moving Tipo, Percentuale & Importo under the "ScontoMaggiorazione" object in the first transformation as in the following: ...
"@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].ScontoMaggiorazione[&1].Tipo"
... If you are trying to group those values under an array then use # instead of &1 , as follows: "@": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].ScontoMaggiorazione[#].Tipo" Using &1 ended up creating null object which probably caused the generation of "Importo" : "." in later transformation. If that helps please accept solution.
... View more
10-30-2023
07:51 AM
Hi @PradNiFi1236 , I would try to do this in two shift operations: The first shift will extract "AltriDatiGestionali" value and put it in higher level than the array its contained in. The second shift will go into each "DettaglioLinee" element and extract each element where Natura value is 3.5N then redirect all the values accordingly and then redirect the "AltriDatiGestionali" from the first shift level to each element as well. The jolt spec will be as follows: [
{
"operation": "shift",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
"AltriDatiGestionali": "FatturaElettronicaBody.DatiBeniServizi.AltriDatiGestionali",
"*": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&1].&"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"FatturaElettronicaBody": {
"DatiBeniServizi": {
"DettaglioLinee": {
"*": {
"Natura": {
"N3.5": {
"$": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].Natura",
"@(2,NumeroLinea)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].NumeroLinea",
"@(2,PrezzoUnitario)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].PrezzoUnitario",
"@(2,ScontoMaggiorazione)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].ScontoMaggiorazione",
"@(4,AltriDatiGestionali)": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&3].AltriDatiGestionali"
}
}
}
}
}
}
}
}
] Note: The spec doesn't include all key\value for each array element but you can follow the what specified to add others as needed. Hope that helps.
... View more
10-10-2023
12:13 PM
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
... View more
10-10-2023
10:40 AM
1 Kudo
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"
}
}
}
}
}
]
... View more
10-03-2023
08:12 AM
@Kiranq, What I found is that the JoltTransformRecord expects only single record to work with hence the name. I noticed when I try to pass an array I was getting the error "...error transforming the first record", however if I pass just one json record it works. If you have an array of json\csv and you are looking to split and process each record individually then I would suggest that you split the records before the JoltTransformRecord. If you dont want to split the array then I recommend using JoltTranformJson first and then use Convert Record processor to convert to CSV.
... View more