-
-
Notifications
You must be signed in to change notification settings - Fork 586
Allow to not skip empty not inline array root node #611
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
Conversation
probably yes, will add an option to configure it |
It seems very marginal, I would be more inclined to just merge it. It only breaks if you literally compare string values, no? |
Please wait, will fix it tomorrow. I have some usecases On 25 Jul 2016 6:41 pm, "Johannes" [email protected] wrote:
|
Added configuration option that allows to chose the default serialization strategy. class User {
/**
* @Serializer\XmlList(inline = false, entry = "comment", skip_when_empty=false)
* @Serializer\Type("array")
*/
public $data = [];
} this will add the new behaviour serializing it into: <result>
<data/>
</result> |
/** | ||
* @var boolean | ||
*/ | ||
public $skip_when_empty = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use this casing for other annotations? I think we already use camelCasing, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, will fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
🎉 |
thanks! any plan for a (there are some PR pretty safe to merge that can be good to include in a hypothetical 1.2 release) |
The current implementation skips the root node for not inline arrays when serializing into XML.
Given:
The previous output was:
<result/>
The new behaviour is:
Should this be considered a BC break?probably yes
This change is consistent with the existing JSON and YML implementations since the output is
{ "data": [] }