First of all, sorry about my english.. I'll try to express in the better way.
I'm building an API Rest in Symfony 2.7 with JMSSerializerBundle. I got a Customer model with address properties separated: (line1, line2, city, postal_code, state, country_code), when i'm sending the response, i'm doing this:
{
"company_name": "Foograde",
"first_name": "Federico",
"last_name": "Balderas Mata",
"email": "federico.balderas@foograde.com.mx",
"address": {
"line1": "Gral. Ortega #223D",
"city": "Celaya",
"state": "Guanajuato",
"postal_code": "38010",
"country_code": "MX"
}}
Like you see, i'm sending parameter on an address object:
/**
* Get address
* @VirtualProperty
* @return array
* @SerializedName("address")
*/
public function getAddress()
{
return array(
'line1' => $this->line1,
'line2' => $this->line2,
'line2' => $this->line3,
'city' => $this->city,
'state' => $this->state,
'postal_code' => $this->postal_code,
'country_code' => $this->country_code
);
}
But now what i'm trying to do is get the request in the same form, with an address object and separate the properties to insert them in the database.
Any idea?