Forum Discussion

Aravind711's avatar
Aravind711
New Contributor II
8 years ago

Json File generation from Redshift Table

Hi All,

I am working on generating a JSON file from a Redshift table in the below desired format

Required Output:

{
“data”: [
{
“classification_code”: “ARGENTINA”,
“reporting_country”: “Argentina”,
“sub_region”: “Rest of Latin America”,
“territory”: “LA”,
“global_region”: “Americas”,
“worldwide”: “Worldwide”,
“pos_customer_id”: 8,
“pos_customer_site_id”: 13
}
]
}

But My original Output is like the below from Snaplogic

{
“classification_code”: “ARGENTINA”,
“reporting_country”: “Argentina”,
“sub_region”: “Rest of Latin America”,
“territory”: “LA”,
“global_region”: “Americas”,
“worldwide”: “Worldwide”,
“pos_customer_id”: 8,
“pos_customer_site_id”: 13
}

Can any one guide me to get the Required output ( I need the Data Tag to be hard coded, as it is required for the UI development )

Thanks,
Aravind

5 Replies

  • cstewart's avatar
    cstewart
    Former Employee

    This can be achieved simply using a Mapper snap and applying the mapping from $ to $data:

    Does this achieve what you’d like?

    • Aravind711's avatar
      Aravind711
      New Contributor II

      Thanks @cstewart
      I don’t want the data to be repeated, i followed the steps you said and got the output as like the above screenshot.

      Please suggest a way to get data like

      {
      “data”: [
      {
      “classification_code”: “ARGENTINA”,
      “reporting_country”: “Argentina”,
      “sub_region”: “Rest of Latin America”,
      “territory”: “LA”,
      “global_region”: “Americas”,
      “worldwide”: “Worldwide”,
      “pos_customer_id”: 8,
      “pos_customer_site_id”: 13
      },
      {
      “classification_code”: “ARGENTINA”,
      “reporting_country”: “Argentina”,
      “sub_region”: “Rest of Latin America”,
      “territory”: “LA”,
      “global_region”: “Americas”,
      “worldwide”: “Worldwide”,
      “pos_customer_id”: 9,
      “pos_customer_site_id”: 15
      },
      {
      “classification_code”: “ARGENTINA”,
      “reporting_country”: “Argentina”,
      “sub_region”: “Rest of Latin America”,
      “territory”: “LA”,
      “global_region”: “Americas”,
      “worldwide”: “Worldwide”,
      “pos_customer_id”: 10,
      “pos_customer_site_id”: 15
      }
      ]
      }

      • Aravind711's avatar
        Aravind711
        New Contributor II

        This is what, I did in JSON generator, PFB screenshot