bazaarvoice / jolt

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

Conditional field + Nested Array #831

Open gaurav-ss opened 5 years ago

gaurav-ss commented 5 years ago

First of all, congratulations on this wonderful tool. It works even better than advertised.

I have a case I have been trying to solve for some time now. I have a conditional transformation with nested arrays and I simply cant seem to make it work. First Input { "transportType": "VEHICLE", "mechanical": "yes", "types": [ { "type": "car", "door": "4", "wheels": 4 }, { "type": "bus", "door": "3", "wheels": 6, "fare": 32 } ] }

And the other input is { "transportType": "HORSE", "mechanical": "no", "type": "horse", "legs": "4", "attribute": "speed" }

The second case is simple and works fine. But the first one with the nested array in there is not working. Can you help steer me in the correct direction?

Spec [ { "operation": "shift", "spec": { "transportType": { "VEHICLE": { "#pollutor": "yes", "@(2,mechanical)": "automtive", "@(3,types[0].type)": "vehicleType[0].type" }, "HORSE": { "@(2,mechanical)": "automtive", "@(2,type)": "animal.type", "@(2,legs)": "animal.legs", "@(2,attribute)": "animal.attribute" }, "null": { "# ": "MTA" } } } } ]

Regards. Gaurav.

wisthy commented 5 years ago

can you share the expected output so that we can figure out what you mean by "it's not working"?