10-16-2021 12:56 AM
Hi
We are just starting off with SnapLogic and we wonder if somebody can give us some answers to the following questions.
We have the following input
[
{
transactionId:“F59AE026-8AEA-4F69-BE97-F7AB981AC3BF”,LineCreationSequenceNumber:1,ItemNumber:“99999999991”,OrderedSalesQuantity:1,SalesPrice:120,AVAPromotionCode:null,SalesUnitSymbol:“UN”,SalesProductCategoryName:null,AVALaserText:null,AVAWrappingText:null,
original:{erpOrderNumber:“JEM-99999”,clientOrderNumber:“00118204”}
},
{
transactionId:“F59AE026-8AEA-4F69-BE97-F7AB981AC3BF”,LineCreationSequenceNumber:2,ItemNumber:“99999999994”,OrderedSalesQuantity:2,SalesPrice:80.93,AVAPromotionCode:null,SalesUnitSymbol:“UN”,SalesProductCategoryName:null,AVALaserText:null,AVAWrappingText:null,
original:{erpOrderNumber:“JEM-99999”,clientOrderNumber:“00118205”}
}
]
I have the following questions
Thanks for your help
10-16-2021 10:16 AM
Hello @Richard,
All your requirements can be done with the “Mapper” snap.
To remove any field from the JSON input, you can simply check the “Pass through” option in the Mapper, then in the “Expression” field, write the field from the input that you want removed, but leave the “Target path” empty. This will remove the field from the input object.
To remove the field “transactionId” you can do the same as above.
I’m not sure which lines you want to convert here into an array, can you elaborate on this ?
10-17-2021 04:27 AM
Thanks for you answers, really appreciate it.
The above lines will have to put in an array if possible.
Further I did try to do your way of removing the original but in my case it worked once but the strange thing is that further on in the pipeline when I tried to do the same thing again it gives me an error that it cannot find the original, even though I can see it in he input schema. Have you seen that before?
Thanks
10-17-2021 10:12 AM
@Richard ,
If you want to put each object into an array then write the following expression:
sl.ensureArray($.filter((val, key) => key != "original" && key != "transactionId"))
This expression will remove the original and transactionId fields from the input and put all fields into an array.
You can check all sl functions here: SL Functions.
If you want to put all objects into a single array then uste the Group by N snap, but change the expression in the Mapper to $.filter((val, key) => key != "original" && key != "transactionId")
Result:
I don’t know about this issue, if there is original in the input schema it should remove it without any problem, try validating the pipeline first and see if there is original object in the output data.
10-23-2021 09:07 AM
Hi all,
I’m relatively new to JSON. For the example data that Richard provides can someone tell me what the proper syntax is to use in the JSON Generator snap? From the JSON Generator snap I’ve tried to Import the json data and I’m getting errors. One of the errors I’m seeing is 'Verify that the table values and the template are correct".
Thanks,
Vin