Forum Discussion

Yashb81's avatar
Yashb81
New Contributor
2 years ago
Solved

Do JSON mapping in a single mapper

Hi Everyone,

This is my sample JSON data.

I want to map this data in a single mapper in order to get the result set below.

Currently I am using too many snaps to do the same. I want to reduce my number of snaps and get it done in 1 mapper.

  • Hi @kkishore,

    Group the incoming data by CARRIERCODE & SHIPCARRIERTRACKINGNUM:

    And add the following expression in a mapper after the group by snap:

    $group.map(x=>{[x.DATETIMETYPE+"_DATETIMEVALUE"]:x.DATETIMEVALUE,[x.DATETIMETYPE+"_DATEVALUE"]:x.DATEVALUE}).reduce((acc,curr)=>acc.extend(curr),{}).extend($groupBy)

    Hope this helps,
    Regards

2 Replies