serializer: XmlList(skipWhenEmpty=true) or @SkipWhenEmpty() does not work

Hello,

I am trying to deserializer an arraycollection, however this attribute is optional, but the following error occurs: “Warning: JMS \ Serializer \ XmlDeserializationVisitor :: visitProperty (): Node no longer exists”


namespace Presentation\DataTransferObject;

use Doctrine\Common\Collections\ArrayCollection;
use JMS\Serializer\Annotation as A;
use Presentation\DataTransferObject\ListTest;

/**
 * @A\XmlRoot("Test")
 */
class Test
{
   /**
     * @var ListTest
     * @A\Type("ArrayCollection<Presentation\DataTransferObject\ListTest>")
     * @A\SkipWhenEmpty()
     * @A\XmlList(skipWhenEmpty=true,entry = "Presentation\DataTransferObject\ListTest")
     */
    private $ListTest;
}

Is there any way to when it is empty, it does not deserialize?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18

Most upvoted comments

  • for XML, recommended specifying@SerializedName
  • for XML arrays recommended specifying for @XmlList the namespace property
  • entry="child::*" is not valid, please put the node name

to higlight the code you can use

```php for php 

```xml for xml
```js for javascript
... and so on

more info on https://help.github.com/articles/creating-and-highlighting-code-blocks/