Member since
07-10-2024
13
Posts
6
Kudos Received
0
Solutions
10-31-2024
04:55 PM
2 Kudos
Hi @Syed0000 , Sorry for the delay. You json is quite complex and very nested which make jolt very hard to write. You probably know your data very well and my recommendation before writing jolt for such Json is that you try to simplify it first by stripping un need blocks and\or flattening the structure where the transformation is not going to be on the same nested level. I honestly tried but when the jolt got so nested it got harder to reference the upper fields and upper array indexes to maintain the same array position and then maintain the required grouping of fields, and may be that is the draw back of using jolt spec in these scenarios (without prior simplification of course :). This leads me to the second option, which I think I have mentioned to you in prior post regarding using JSLT Transformation instead. JSLT is better option in these cases because you can traverse the structure much easier , and since you have some condition on how to set fields and values this also would be easier to achieve with some expression language like if-else . For example if we take the transformation to create catalogCondition strucutre which seems to the most complex, here is how the jstl looks like: let paths ={
"paths":[for(.tiers)
{
for(.conditions)
"catalogCondition":
{
"category":
[for(.conditionsMerch)
{
"include": if(.excludeInd==0) "yes" else "no",
"categoryList":[.webCategoryId]
}
if(.merchandiseLevel!=5 and not(.keyItemNum))]
}
+
{
"products" : [for(.conditionsMerch)
{
"include": if(.excludeInd==0) "yes" else "no",
"productList":[.keyItemNum]
}
if(not(.webCategoryId))]
}
}
]
}
{
"pricePaths": $paths
} I know this might look a little intimidating at beginning but its not near as bad as when you try to do it with jolt. I understand that jstl is bit of learning curve but I believe it would save you tons of time long term specially when dealing with long, complex and nested Json transformation. I know this is not the answer you were looking for but hopefully this can help you when facing other json transformation challenges in the future. Good luck.
... View more
07-25-2024
10:53 AM
1 Kudo
Hi, Sorry for the delay. See if this will work: [
{
"operation": "shift",
"spec": {
"tiers": {
"*": {
"priceRuleAttributes": {
"*": {
"id": {
"PR_CURR_CONDITION": {
"@(2,values[0])": "paths.[&5].currencyCondition[#2].currency"
}
}
}
},
"rewards": {
"*": {
"changeType": "paths.[&3].calculatePrice[&1].calculationType",
"changeAmount": "paths.[&3].calculatePrice[&1].amount",
"changePercent": "paths.[&3].calculatePrice[&1].percentage",
"@(2,priceRuleAttributes)": {
"*": {
"id": {
"PR_CURR_CONDITION": {
"@(2,values[0])": "paths.[&7].calculatePrice[&4].Currency"
}
}
}
}
}
}
}
}
}
}
]
... View more
07-12-2024
10:18 AM
For jslt , like I said sometimes its easier to write and work with specially if you are trying to get\aggregate data from heavily nested structure. The other advantage jslt has its ability to traverse nested levels dynamically using recursive function calls for example lets say you are working with json structure but have no idea how many nested level it might have (see my json\jslt answer in the this post to get an idea what I mean by that ). On the other hand jolt appears to perform a little bit better in comparison but they are very close. In regards to your question you use the follow to extract single value for the path name: "@(2,values[0])": "paths.[&5].pathName"
... View more
07-11-2024
08:22 AM
can i get single value instead of array ? "branchName" : ["MEMBERS"] --> "branchName" : "MEMBERS" [ {
"ID" : "09878666",
"DATE" : "2022-01-01",
"NAME" : "test_1",
"branchName" : "MEMBERS",
}, {
"ID" : "09878666",
"DATE" : "2022-01-01",
"NAME" : "test_2",
"branchName" : "NON MEMBERS"
} ]
... View more