I work with Symfony project. I'm a newbie with design pattern and I would like to apply it. My context is : I would like have a function receive an input json -> decode into an array -> get some necessary data in that array -> store in a column of a table with json type. My expected with my function when apply design pattern is : it could receive different structure json, but finally, it will return same structure json. Example:
- Input json 1:
{
"contactdata": {
"mobilephone": "",
"email": ""
},
"userdata": {
"birthday": {
"status": "",
"value": "1/1/2021"
},
"firstname": {
"status": "",
"value": "My first name 1",
},
"lastname": {
"status": "",
"value": "My last name 1",
}
}
}
Expected return json:
{
"first_name" : "My first name 1",
"last_name": "My last name 1",
"birthday": "1/1/2021"
}
- Input json 2:
{
"STATUS": true,
"PERSONALDETAILS": {
"APPLICANTFIRSTNAME": "My first name 2",
"APPLICANTLASTNAME": "My last name 2",
}
}
Expected return json:
{
"first_name" : "My first name 2",
"last_name": "My last name 2",
"birthday": ""
}
I see many design pattern type and I'm learning about Visitor. I don't know if it could apply for my context or another design pattern will be better?
Aucun commentaire:
Enregistrer un commentaire