Description
This package helps in converting the incoming json to target json format. The use of this package is as follows:
var output = ezmapper(input,data);
- input - This is the mapping details to be provided for conversion. Pipe symbol can be used if you want to map same object to 2 different o/p json attributes
- data - This is the incoming data
Input Formats
This is the output format:
input:{
"Person.firstName":
"Info.Details.Name.FirstName",
"Person.lastName":
"Info.Details.Name.LastName",
"Person.address.addressLine":
"Info.Details.Type.addressLine",
"Person.address.addressLine2":
"Info.Details.Type.addressLine2|AddressInfo.addressLine2",
}
This is the data that needs to be converted as mentioned in the output format
data = {
Person: {
firstName: "First",
lastName: "Last",
address: [
{
addressLine: "223",
addressLine2: "Main street",
},
{
addressLine: "224",
addressLine2: "Main Bridge street",
},
],
},
};
This the actual formatted output generated:
output:
{
"Info": {
"Details": {
"FirstName": "First",
"LastName": "Last",
"Type": [
{
"addressLine": "223",
"addressLine2": "Main street"
},
{
"addressLine": "224",
"addressLine2": "Main Bridge street"
}
]
}
},
"AddressInfo": [
{
"addressLine2": "Main street"
},
{
"addressLine2": "Main Bridge street"
}
]
}