symfony/symfony — pull request #10496 by steffkes (2014-03-19 20:16:29+00:00)
Title: [HttpFoundation] json_encode options

| Q | A
| ------------- | ---
| Bug fix? | [no]
| New feature? | [no]
| BC breaks? | [no]
| Deprecations? | [no]
| Tests pass? | [yes]
| Fixed tickets | -
| License | MIT
| Doc PR | -

PR #9915 introduced the possibility to overwrite the options we use while calling ``json_encode`` - right now, if i want to extend ``JsonResponse`` i have to call ``setEncondingOptions`` in my constructor which causes the encoded string to be decoded and re-encoded again (this time using the correct/intended options).

if we would rely on ``getEncodingOptions`` in the first place, we could save one roundtrip, since my own ``JsonResponse`` could define ``getEncodingOptions`` like this:

protected function getEncodingOptions()
{
return parent::getEncodingOptions() | JSON_PRETTY_PRINT;
}

and there would be no need to decode & re-encoding the whole thing at all - just because i would want to have pretty printed json.

WDYT?