I have a REST API that receives some JSON data. The fields in this data come from another records systems that uses different names to refer to the same things.
For this reason, I need to map the fields in the incoming object to fields in the object which I will store in our database. So for example, the incoming object might look like:
{
"caseId": 9876
"userId": 123456,
}
and the outgoing object will need to be
{
"case_id": 9876
"user": {
"id": 123456
}
}
Mapping fields like caseId is easy enough. But for fields like userId where I may potentially need to map them several levels deep into nested objects, is there any library or easy technique to do such a mapping? The ideal solution would allow me to specify the mappings like so:
{
"caseId": "case_id",
"userId": "user.id"
{