From 9480e2b352610c156956acdd326f0168c7e8fd4c Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 5 Aug 2022 14:59:23 +0200 Subject: [PATCH] enable JSON_PRESERVE_ZERO_FRACTION by default this makes json output float values that happen to be full numbers with a `.0`, so `4.0` or `0.0` instead of `4` resp `0`. that in turn helps when consuming the json in a type-safe language. --- src/Symfony/Component/Serializer/Encoder/JsonEncode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php index 86baf99994eb6..898b69db8977d 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php @@ -23,7 +23,7 @@ class JsonEncode implements EncoderInterface public const OPTIONS = 'json_encode_options'; private $defaultContext = [ - self::OPTIONS => 0, + self::OPTIONS => \JSON_PRESERVE_ZERO_FRACTION, ]; public function __construct(array $defaultContext = [])