[HttpFoundation] Add ability to change JSON encoding options

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Tests pass?   | yes
| Fixed tickets | #9086
| License       | MIT