I am not sure if this question has been asked before but I can't find related custom mapping. Usually it is a direct JSON to object 1:1 mapping.
So here is my sample example:
class Test():
id: str
name: str
msg: str
data = [
{
"id": "12345",
"client": "test",
"msg": "random"
}, {
"id": "54321",
"client": "test-2",
"msg": "random-2"
}
]
So on above I have a JSON, I wanted to directly convert it to object I have on the first class.
Note the "client" from the JSON becomes name
.
So the final output when I do load the object it would become.
data = [
{
"id": "12345",
"name": "test",
"msg": "random"
}, {
"id": "54321",
"name": "test-2",
"msg": "random-2"
}
]