Skip to main content

Hi,

 

Can anyone help this transformation.

 

I need to create single json object from given input json, in address, Issuer_contact lits have type codes, based on type codes in lists i need to form json request like below output json

 

Input JSON:

 

{

"HapRec": "260A",

"IssuerTypeCode": "1080",

"FirstName": "Joy",

"MiddleName": "H",

"LastName": "Marcus",

"address": [{

"ad_Type_Code": "1100",

"addline1": "1 office mail",

"addline2": "2 office street address",

"city": "Vegas",

"state": "CA",

"zipCode": "67890"

},

{

"ad_Type_Code": "2200",

"addline1": "1 home mail",

"addline2": "2 home street address",

"city": "Jesey",

"state": "NJ",

"zipCode": "12345"

}

],

"Issuer_contact": [{

"contact_type": "3344",

"contactNumber": "333-699-8787"

},

{

"contact_type": "3170",

"contactNumber": "754-676-4343"

}

]

}

 

Output JSON:

 

{

"HapRec": "260A",

"IssuerTypeCode": "1080",

"FirstName": "Joy",

"MiddleName": "H",

"LastName": "Marcus",

"work-addline1": "1 office mail",

"work-addline2": "2 office street address",

"work-city": "Vegas",

"work-state": "CA",

"work-zipCode": "67890",

"client-home-addline1": "1 home mail",

"client-home-addline2": "2 home street address",

"client-home-city": "Jesey",

"client-home-state": "NJ",

"client-home-zipCode": "12345",

"issuer-contactNumber": "333-699-8787",

"client-Number": "754-676-4343"

}

3 answers
  1. Jul 22, 2018, 3:58 PM

    Thank you for your quick response @manik , i have a qustion. Here you have hard coded array values here.

     

    addrList[0] ++ addrList[1] ++ contactNumbers[0] ++ contactNumbers[1]

     

    If input json have number of address objects in dynamic address list, how we have to handle?

     

    "address": [{

    "ad_Type_Code": "1100",

    "addline1": "1 office mail",

    "addline2": "2 office street address",

    "city": "Vegas",

    "state": "CA",

    "zipCode": "67890"

    },

    {

    "ad_Type_Code": "2200",

    "addline1": "1 home mail",

    "addline2": "2 home street address",

    "city": "Jesey",

    "state": "NJ",

    "zipCode": "12345"

    },

    {

    "ad_Type_Code": "5600",

    "addline1": "1 office mail",

    "addline2": "2 primary street address",

    "city": "Edison",

    "state": "NJ",

    "zipCode": "07545"

    },

    {

    "ad_Type_Code": "5200",

    "addline1": "secondary mail add1 ",

    "addline2": null,

    "city": "Reston",

    "state": "VA",

    "zipCode": "20176"

    }

    ]

0/9000