Make sure JSON request bodies are parsed as array.

Refs #533.
This commit is contained in:
Franz Liedke 2015-09-22 15:19:54 +02:00
parent 7c37320891
commit efee030bf1

View File

@ -24,6 +24,10 @@ class ReadJsonParameters implements MiddlewareInterface
if (str_contains($request->getHeaderLine('content-type'), 'json')) {
$input = json_decode($request->getBody(), true);
if (! is_array($input)) {
$input = [];
}
foreach ($input as $name => $value) {
$request = $request->withAttribute($name, $value);
}