Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Transform the given input json, based on array size of an element

Transform the given input json, based on array size of an element

New Contributor

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

}

}