From 367efdb0ea5ef8648d857660623a7d59701ce36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20G=C3=B6kalp?= Date: Sat, 30 Jan 2021 18:31:32 +0300 Subject: [PATCH] JsonResponse content updated --- components/http_foundation.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 0fa78dc6439..449d29ea0f0 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -668,9 +668,11 @@ class, which can make this even easier:: // if you know the data to send when creating the response $response = new JsonResponse(['data' => 123]); - // 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 $response = new JsonResponse(); // ... + // configure any custom encoding options (if needed, it must be called before "setData()") + //$response->setEncodingOptions(JsonResponse::DEFAULT_ENCODING_OPTIONS | \JSON_PRESERVE_ZERO_FRACTION); $response->setData(['data' => 123]); // if the data to send is already encoded in JSON