-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Description
Currently scalar numeric values are passed directly to the Encoders
which is then formatted into string:
symfony/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php
Lines 463 to 464 in 3711a6a
} elseif (is_numeric($val)) { | |
return $this->appendText($node, (string) $val); |
for the xml i am working on, i would like to have the floating points fixed, so it can be serialized into:
<element>12.50</element>
instead of this:
<element>12.5</element>
my current tests for my library using Serializer does read the XML into Objects and writes them back into XML again and compares the XML-Strings. These differences currently make the Tests fail.
because this might depend on the properties, it might need to be done in AbstractObjectNormalizer too:
symfony/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
Lines 212 to 214 in 3711a6a
if (null === $attributeValue || \is_scalar($attributeValue)) { | |
$data = $this->updateData($data, $attribute, $attributeValue, $class, $format, $attributeContext, $attributesMetadata, $classMetadata); | |
continue; |
The ScalarNormalizer might need to be format specific, like it should only do Numeric to FormatString for XML, not for JSON
Example
No response