bazaarvoice / jolt

JSON to JSON transformation library written in Java.
Apache License 2.0
1.56k stars 329 forks source link

How to grab the second value of the duplicate keys? #1226

Open mpanwala-wyn opened 11 months ago

mpanwala-wyn commented 11 months ago

Here there are two values for the same "AttributeId": "7cf656a0-1f74-4ed0-bb06-7de031f6e05c" and every time if there are duplicate attributeIds I need to select the second value only, how would I do that in Jolt?

Input:

{ "sku": "00079821000742", "assets": [ { "AttributeId": "93d22e97-989a-49ed-b499-53909ae70cc2", "Value": "f3ba8979-a3b1-444b-b34b-3852b189a700" }, { "AttributeId": "1b39ba3d-501e-4951-ae61-4259a63ce400", "Value": "9a812cf5-1d54-40c7-a936-e3bef4125ade" }, { "AttributeId": "379b01a0-112d-4f55-92c1-ce3a8e5af045", "Value": "a169c58d-87f3-4c68-a02f-dce46a036e4d" }, { "AttributeId": "7cf656a0-1f74-4ed0-bb06-7de031f6e05c", "Value": "e3bb9fb3-c9f1-4cc0-ae9b-0c90b15da74d" }, { "AttributeId": "7cf656a0-1f74-4ed0-bb06-7de031f6e05c", "Value": "8d28fb65-8fd4-4659-b0e1-367f708100a9" } ] }

Expected Output: { "sku" : "00079821000742", "assets" : [ { "AttributeId" : "93d22e97-989a-49ed-b499-53909ae70cc2", "Value" : "f3ba8979-a3b1-444b-b34b-3852b189a700" }, { "AttributeId" : "1b39ba3d-501e-4951-ae61-4259a63ce400", "Value" : "9a812cf5-1d54-40c7-a936-e3bef4125ade" }, { "AttributeId" : "379b01a0-112d-4f55-92c1-ce3a8e5af045", "Value" : "a169c58d-87f3-4c68-a02f-dce46a036e4d" }, { "AttributeId" : "7cf656a0-1f74-4ed0-bb06-7de031f6e05c", "Value" : "8d28fb65-8fd4-4659-b0e1-367f708100a9" } ] }