# How to do data mapping between two different payloads using datamapper

In this tutorial we are going to transform an incoming message payload to a different payload structure acceptable for the target system. The target systems expects the message in the following model.

Following is the incoming payload message for this use case.

 [{
 	"VehicleNo": "AT6783-00",
 	"Location": "NSW",
 	"Owner": "Harry",
 	"Address": {
 		"Street": "Rosley St",
 		"Unit": 88,
 		"State": "NSW",
 		"PIN": "2134"
 	},
 	"VehicleInfo": {
 		"Type": "HatchBack",
 		"Name": "Honda",
 		"EngineNo": "343 - 5993 - 99"
 	}
 },
 {
 	"VehicleNo": "AQ888-00",
 	"Location": "VIC",
 	"Owner": "Dan",
 	"Address": {
 		"Street": "Redfern St",
 		"Unit": 12,
 		"State": "VIC",
 		"PIN": "2220"
 	},
 	"VehicleInfo": {
 		"Type": "HatchBack",
 		"Name": "KIA",
 		"EngineNo": "343 - 3333 - 99"
 	}
 },
 {
 	"VehicleNo": "AT9992-00",
 	"Location": "NSW",
 	"Owner": "Chris",
 	"Address": {
 		"Street": "Edmond St",
 		"Unit": 87,
 		"State": "NSW",
 		"PIN": "2123"
 	},
 	"VehicleInfo": {
 		"Type": "Sedan",
 		"Name": "BMW",
 		"EngineNo": "500 - 5003 - 99"
 	}
 },
 {
 	"VehicleNo": "AJ8990-00",
 	"Location": "WA",
 	"Owner": "Stanley",
 	"Address": {
 		"Street": "Ross St",
 		"Unit": 312,
 		"State": "WA",
 		"PIN": "3123"
 	},
 	"VehicleInfo": {
 		"Type": "HatchBack",
 		"Name": "Honda",
 		"EngineNo": "333 - 700 - 99"
 	}
 }
]

Following is the JSONata expression in the datamapper used.

   {
       "VehicleRegDetails": $map($, function($v) {
        {
          "OwnerName" : $v.Owner,
          "VehicleNo": $v.VehicleNo,
          "Location" : $v.Address.State,
          "Car_Name" : $v.VehicleInfo.Type,
          "Car_EngineNo" : $v.VehicleInfo.EngineNo,
          "Car_Type" : $v.VehicleInfo.Type
        }
        
        })
}

Link to video