Skip to main content

Hi,

How can I merge JSON Data Node in array while using Dataraptor transform.

 

How can I merge JSON Data Node in array while using Dataraptor transform.

 I am trying to achieve the following JSON : 

{

    "Forecast": [

        {

            "Date": "2021-01-26",

            "Condition": "Heavy Snow",

            "HiLoTempF": "30.5/21.7",

            "HiLoTempC": "-0.8/-5.7"

        },

        {

            "Date": "2021-01-27",

            "Condition": "Light Snow",

            "HiLoTempF": "31.7/22.8",

            "HiLoTempC": "-0.2/-5.1"

        },

        {

            "HiLoTempF": "31.0/18.7",

            "Date": "2021-01-28",

            "Condition": "Flurries",

            "HiLoTempC": "-0.6/-7.8"

        },

        {

            "HiLoTempF": "25.3/18.1",

            "Date": "2021-01-29",

            "Condition": "Clear sky",

            "HiLoTempC": "-3.7/-7.7"

        },

        {

            "HiLoTempF": "24.2/19.7",

            "Date": "2021-01-30",

            "Condition": "Clear sky",

            "HiLoTempC": "-4.3/-6.8"

        }

    ],

    "Current": {

        "Condition": "Heavy Snow",

        "CityState": "Schenectady, New York",

        "TempF": 27.5,

        "TempC": -2.5

    },

    "CurrentIcon": "www.weatherbit.io/static/img/icons/s03d.png",

    "ForecastIcon": "www.weatherbit.io/static/img/icons/s01d.png"

}

 

But I'm Getting Forecast Data in each separate node:

[

  {

    "Forecast": {

      "Date": "2021-08-02"

    },

    "ForecastIcon": "www.weatherbit.io/static/img/icons/r03d.png",

    "Current": {

      "TempF": 17.2,

      "CityState": "Roosevelt Island, NY",

      "Condition": "Clear sky"

    },

    "CurrentIcon": "www.weatherbit.io/static/img/icons/c01n.png"

  },

  {

    "ForecastIcon": "www.weatherbit.io/static/img/icons/r02d.png",

    "Current": {

      "TempF": 17.2,

      "CityState": "Roosevelt Island, NY",

      "Condition": "Clear sky"

    },

    "CurrentIcon": "www.weatherbit.io/static/img/icons/c01n.png"

  },

  {

    "ForecastIcon": "www.weatherbit.io/static/img/icons/r02d.png",

    "Current": {

      "TempF": 17.2,

      "CityState": "Roosevelt Island, NY",

      "Condition": "Clear sky"

    },

    "CurrentIcon": "www.weatherbit.io/static/img/icons/c01n.png"

  },

  {

    "ForecastIcon": "www.weatherbit.io/static/img/icons/r01d.png",

    "Current": {

      "TempF": 17.2,

      "CityState": "Roosevelt Island, NY",

      "Condition": "Clear sky"

    },

    "CurrentIcon": "www.weatherbit.io/static/img/icons/c01n.png"

  },

  {

    "ForecastIcon": "www.weatherbit.io/static/img/icons/c04d.png",

    "Current": {

      "TempF": 17.2,

      "CityState": "Roosevelt Island, NY",

      "Condition": "Clear sky"

    },

    "CurrentIcon": "www.weatherbit.io/static/img/icons/c01n.png"

  }

]

 

#Trailhead #Vlocity #Json

1 个回答
  1. 2021年8月3日 11:07

    Hello @Asheesh Sahu,

    You need to add 4 formulas like below :

     

    Hello ,You need to add 4 formulas like below : Now in the Transform section, Match Input and Output JSON Path like below: After successfully doing above things you will get the desired result in the f

     

    1627988397410.jpg

    Now in the Transform section, Match Input and Output JSON Path like below:

     

    1627988397398.jpg

     

    After successfully doing above things you will get the desired result in the format as you are expecting!

     

    1627988397430.jpg

     

    Hope it helps:)

    Let me know if you have nay doubts!! Please feel free to mark as best answer if that helps!!

    Thanks :D

0/9000