Commit b8eb2d1a authored by Fabien Potencier's avatar Fabien Potencier

merged branch jalliot/patch-1 (PR #292)

Commits
-------

c9bbcc0a Use new json function in doc

Discussion
----------

Use new json function in doc

---------------------------------------------------------------------------

by igorw at 2012-03-24T16:53:00Z

Missed that one, thanks. 👍
parents 1d62671c c9bbcc0a
......@@ -602,17 +602,11 @@ correctly, to prevent Cross-Site-Scripting attacks.
auto-escaping mechanisms.
* **Escaping JSON**: If you want to provide data in JSON format you should
use the PHP ``json_encode`` function::
use Symfony\Component\HttpFoundation\Response;
use the Silex ``json`` function::
$app->get('/name.json', function (Silex\Application $app) {
$name = $app['request']->get('name');
return new Response(
json_encode(array('name' => $name)),
200,
array('Content-Type' => 'application/json')
);
return $app->json(array('name' => $name));
});
Console
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment