cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Change format of API response

Akash_Srivastav
New Contributor II

I created a simple pipeline which provides output in following format

[
{
โ€œCURRENCY_CODEโ€: โ€œADPโ€,
โ€œCURRENCY_NAMEโ€: โ€œAndorran Pesetaโ€
},
{
โ€œCURRENCY_CODEโ€: โ€œAEDโ€,
โ€œCURRENCY_NAMEโ€: โ€œUAE Dirhamโ€
},โ€ฆ
]

I want the pipeline output to be like this

{
โ€œapiVersionโ€ : โ€œ1.0โ€,
โ€œCurrenciesโ€: [
{
โ€œCURRENCY_CODEโ€: โ€œADPโ€,
โ€œCURRENCY_NAMEโ€: โ€œAndorran Pesetaโ€
},
{
โ€œCURRENCY_CODEโ€: โ€œAEDโ€,
โ€œCURRENCY_NAMEโ€: โ€œUAE Dirhamโ€
},โ€ฆ
]
}

How can I do this preferably in a mapper, without using any scripting?

image

4 REPLIES 4

tstack
Former Employee

To group multiple documents into one document, youโ€™ll need to use a GroupByN snap configured like so:

image

Setting the group size to zero means that it will collect all of the input documents into a single output.

You can then use a Mapper to add the apiVersion header:

image

Akash_Srivastav
New Contributor II

Thanks @tstack
Your solution worked!

@tstack

I read in documentation that Group by N snap is not available for Ultra pipeline. Is there any alternative ?

SandeepVemula
Contributor

Use Join Snap to Join 2 streams of Data.