By nested json I mean something that keeps address data in its own "address" array:
{
"user": {
"id": 999,
"username": "xxxx",
"email": "[email protected]",
"address": {
"street": "13th avenue",
"place": 12
}
}
}
instead of flat one
{
"user": {
"id": 999,
"username": "xxxx",
"email": "[email protected]",
"street": "13th avenue",
"place": 12
}
}
Flat one is processed fine there using User entity and it's properties: "id", "username" and "email". It is nicely validated using symfony form feature:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('username');
$builder->add('email', 'email');
$builder->add('password', 'password');
$builder->add('street');
$builder->add('place');
}
I want to have both "street" and "place" as properties in User entity, to store it all in one user table in the database, using doctrine. But the json I get comes from third party, so I can not modify it.
Is there any way of constructing the form so it can validate the json with "address" field correctly, still being able to keep all the user data in one table?