Forum Discussion

Akash_Srivastav's avatar
Akash_Srivastav
New Contributor II
7 years ago

Change format of API response

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?

4 Replies

  • tstack's avatar
    tstack
    Former Employee

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

    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:

    • Akash_Srivastav's avatar
      Akash_Srivastav
      New Contributor II

      @tstack

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