[HttpFoundation] Throw proper exception when invalid data is passed to JsonResponse class

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| BC breaks?    | no*
| Tests pass?   | yes
| Fixed tickets | 9903
| License       | MIT

* as described in mentioned issue, before this PR there was thrown exception `UnexpectedValueException`, which was not correct, but I guess some people trying to hide the bug could use `try {} catch` on it.