Skip to content

Commit 367efdb

Browse files
MehGokalpwouterj
authored andcommitted
JsonResponse content updated
1 parent e16bc4e commit 367efdb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/http_foundation.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,11 @@ class, which can make this even easier::
668668
// if you know the data to send when creating the response
669669
$response = new JsonResponse(['data' => 123]);
670670

671-
// if you don't know the data to send when creating the response
671+
// if you don't know the data to send or if you want to customize the encoding options
672672
$response = new JsonResponse();
673673
// ...
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);
674676
$response->setData(['data' => 123]);
675677

676678
// if the data to send is already encoded in JSON

0 commit comments

Comments
 (0)