Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Added docs for JsonResponse::fromJsonString#7204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -547,13 +547,22 @@ class, which can make this even easier:: | ||
| use Symfony\Component\HttpFoundation\JsonResponse; | ||
| // if you know the data to send when creating the response | ||
| $response = new JsonResponse(array('data' => 123)); | ||
| // if you don't know the data to send when creating the response | ||
| $response = new JsonResponse(); | ||
| // ... | ||
| $response->setData(array('data' => 123)); | ||
| // if the data to send is already encoded in JSON | ||
| $response = JsonResponse::fromJsonString('{ "data": 123 }'); | ||
| .. versionadded:: 3.2 | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. wrong version MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Then this blog post is wrong too 😢http://symfony.com/blog/new-in-symfony-3-2-dx-improvements#added-a-named-constructor-to-jsonresponse Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. well, if it is in 3.2, the wrong number is on the next line saying 3.3 (I haven't checked the code to know which version included it) Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. @javiereguiluz 3.2 is correct:symfony/symfony#19552 | ||
| The ``JsonResponse::fromJsonString()`` method was added in Symfony 3.2. | ||
| The ``JsonResponse`` classsets the ``Content-Type`` header to | ||
| ``application/json`` and encodes your data to JSON when needed. | ||
| .. caution:: | ||