-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected
6.1
Description
When serializing a class to an XML string, an attribute with a value of false is lost and replaced with null.
How to reproduce
$dummy = new class {
#[\Symfony\Component\Serializer\Annotation\SerializedName('@test')]
public bool $foo = false;
public bool $bar = false;
};
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$metadataAwareNameConverter = new MetadataAwareNameConverter($classMetadataFactory);
$serializer = new Symfony\Component\Serializer\Serializer([
new ObjectNormalizer($classMetadataFactory, $metadataAwareNameConverter)
], [
new \Symfony\Component\Serializer\Encoder\XmlEncoder()
]);
var_dump($serializer->serialize($dummy, 'xml'));
Possible Solution
No response
Additional Context
Generated XML is now wrong:
<?xml version="1.0"?>
<response test=""><bar>0</bar></response>
Should be:
<?xml version="1.0"?>
<response test="0"><bar>0</bar></response>