-
-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overriding groups of deeper branches of the graph #1121
Comments
Hi, the feature is part of jms/serializer v3.x as described. The PR is #1071
The main aim of the feature is to be able to set a generic group for the whole class, and a specific group for a particular property. As example: use JMS\Serializer\Annotation\Groups;
class User
{
/** @Groups({"generic"}) */
private $name;
/** @Groups({"specific"}) */
private $email;
/**
* @var User
* @Groups({"generic"})
* */
private $manager;
} $context = SerializationContext::create()->setGroups(array(
'generic',
'manager' => array(
'specific',
),
)); will produce something as {
"name": "John",
"manager": {
"email": "[email protected]"
}
} If you had only $context = SerializationContext::create()->setGroups(array(
'generic'
)); Result would have been: {
"name": "John",
"manager": {
"name": "Tom"
}
} |
Hi, |
@graanday do you mean different groups depending on the object value? |
yes I am referring to the example of the object graph in the documentation. |
I guess you'd like to use it for the exclusion, right? |
The documentation is not clear.
What do mean
manager
andfriends
array keys passed tosetGroups
in array?Are those names of the properties on the object to be serialized?
Is this feature is working at all?
#1058
This seemed to remove part or all of it?
The text was updated successfully, but these errors were encountered: