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 06-26-2019 11:07 AM
Hi, I need some help with JOLT-syntax.
JSON-Input
{
"nummer": "22",
"id": "177",
"table": [
{
"zn": 1,
"stfflbisart": 10
},
{
"zn": 2,
"stfflbisart": 50
}
]
}JOLT-Specification
[{
"operation": "shift",
"spec": {
"id": "ID",
"nummer": "Nummer",
"table": {
"*": {
"zn": "ArtikelPreise_Pos.[#2].ZeileNr",
"stfflbisart": "ArtikelPreise_Pos.[#2].StaffelBis"
}
}
}
}, {
"operation": "default",
"spec": {
"Default_Kopf": "${VAR_KD}"
}
}
]
JSON-Output
{
"ID" : "177",
"Nummer" : "22",
"ArtikelPreise_Pos" : [ {
"ZeileNr" : 1,
"StaffelBis" : 10
}, {
"ZeileNr" : 2,
"StaffelBis" : 50
} ],
"Default_Kopf" : "${DFT_KOPF}"
}Like in "Default_Kopf" I need to set a default value to each element of the array "ArtikelPreise_Pos" coming from flowfile attribute "DFT_POS".
The result should look like this:
WANTED JSON-Output
{
"ID" : "177",
"Nummer" : "22",
"ArtikelPreise_Pos" : [ {
"ZeileNr" : 1,
"StaffelBis" : 10,
"Default_Pos" : "${DFT_POS}"
}, {
"ZeileNr" : 2,
"StaffelBis" : 50,
"Default_Pos" : "${DFT_POS}"
} ],
"Default_Kopf" : "${VAR_KD}"
}Tried things like this, but it doesn't work:
[{
"operation": "shift",
"spec": {
"id": "ID",
"nummer": "Nummer",
"table": {
"*": {
"zn": "ArtikelPreise_Pos.[#2].ZeileNr",
"stfflbisart": "ArtikelPreise_Pos.[#2].StaffelBis"
}
}
}
}, {
"operation": "default",
"spec": {
"Default_Kopf": "${DFT_KOPF}",
"ArtikelPreise_Pos": {
"Default_Pos": "${DFT_POS}"
}
}
}
]Any help? Thanks.
Created 06-26-2019 07:29 PM
Try with below jolt spec:
[{
"operation": "shift",
"spec": {
"id": "ID",
"nummer": "Nummer",
"table": {
"*": {
"zn": "ArtikelPreise_Pos.[#2].ZeileNr",
"stfflbisart": "ArtikelPreise_Pos.[#2].StaffelBis"
}
}
}
}, {
"operation": "default",
"spec": {
"Default_Kopf": "${VAR_KD}",
"ArtikelPreise_Pos[]": {
"*": {
"Default_Kopf": "${DFT_POS}"
}
}
}
}
]Output:
{
"ID" : "177",
"Nummer" : "22",
"ArtikelPreise_Pos" : [ {
"ZeileNr" : 1,
"StaffelBis" : 10,
"Default_Kopf" : "${DFT_POS}"
}, {
"ZeileNr" : 2,
"StaffelBis" : 50,
"Default_Kopf" : "${DFT_POS}"
} ],
"Default_Kopf" : "${VAR_KD}"
}I hope this matches with your expected output.
-
If the answer is helpful to resolve the issue, Login and Click on Accept button below to close this thread.This will help other community users to find answers quickly 🙂
Created 06-26-2019 07:29 PM
Try with below jolt spec:
[{
"operation": "shift",
"spec": {
"id": "ID",
"nummer": "Nummer",
"table": {
"*": {
"zn": "ArtikelPreise_Pos.[#2].ZeileNr",
"stfflbisart": "ArtikelPreise_Pos.[#2].StaffelBis"
}
}
}
}, {
"operation": "default",
"spec": {
"Default_Kopf": "${VAR_KD}",
"ArtikelPreise_Pos[]": {
"*": {
"Default_Kopf": "${DFT_POS}"
}
}
}
}
]Output:
{
"ID" : "177",
"Nummer" : "22",
"ArtikelPreise_Pos" : [ {
"ZeileNr" : 1,
"StaffelBis" : 10,
"Default_Kopf" : "${DFT_POS}"
}, {
"ZeileNr" : 2,
"StaffelBis" : 50,
"Default_Kopf" : "${DFT_POS}"
} ],
"Default_Kopf" : "${VAR_KD}"
}I hope this matches with your expected output.
-
If the answer is helpful to resolve the issue, Login and Click on Accept button below to close this thread.This will help other community users to find answers quickly 🙂
Created 06-27-2019 05:59 AM
@Shu Oh, so simple... thank you so much!