We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e16bc4e commit 367efdbCopy full SHA for 367efdb
components/http_foundation.rst
@@ -668,9 +668,11 @@ class, which can make this even easier::
668
// if you know the data to send when creating the response
669
$response = new JsonResponse(['data' => 123]);
670
671
- // if you don't know the data to send when creating the response
+ // if you don't know the data to send or if you want to customize the encoding options
672
$response = new JsonResponse();
673
// ...
674
+ // configure any custom encoding options (if needed, it must be called before "setData()")
675
+ //$response->setEncodingOptions(JsonResponse::DEFAULT_ENCODING_OPTIONS | \JSON_PRESERVE_ZERO_FRACTION);
676
$response->setData(['data' => 123]);
677
678
// if the data to send is already encoded in JSON
0 commit comments