Member since
03-26-2019
1
Post
0
Kudos Received
0
Solutions
03-27-2019
09:42 PM
I have following 3 input json and i wanted them to translate as given. If the 'supported' element array size is 1, i want to translate as flattened json, and if array size > 1 i want to bring out the common key/value and keep the rest of the keys inside the respective attribute. I am not able to come up with the correct jolt spec for this requirement. Please help me on jolt spec. Input json(s): 1. { "data": { "supported":["car"], "car":{ "year":2010, "model":"bmw", "id":12345, "surface":"road" } } } 2. { "data": { "supported":["truck"], "truck":{ "year":2011, "model":"abc", "id":6789, "surface":"road" } } } 3. { "data": { "supported":["car","truck"], "car":{ "year":2010, "model":"bmw", "id":12345, "surface":"road" }, "truck":{ "year":2011, "model":"abc", "id":6789, "surface":"road" } } } Output json(s): 1. { "supported":"car", "year":2010, "model":"bmw", "id":12345, "surface":"road" } 2. { "supported":"truck", "year":2011, "model":"abc", "id":6789, "surface":"road" } 3. { "supported":["car","truck"], "surface":"road", "car":{ "year":2010, "model":"bmw", "id":12345 }, "truck":{ "year":2011, "model":"abc", "id":6789 } }
... View more