diff --git a/Slim/Http/Request.php b/Slim/Http/Request.php index 1d9b89537..1b54f5c9d 100644 --- a/Slim/Http/Request.php +++ b/Slim/Http/Request.php @@ -182,7 +182,7 @@ public function __construct($method, UriInterface $uri, HeadersInterface $header } $this->registerMediaTypeParser('application/json', function ($input) { - return json_decode($input); + return json_decode($input, true); }); $this->registerMediaTypeParser('application/xml', function ($input) { @@ -191,7 +191,7 @@ public function __construct($method, UriInterface $uri, HeadersInterface $header $this->registerMediaTypeParser('application/x-www-form-urlencoded', function ($input) { parse_str($input, $data); - return (object)$data; + return $data; }); } diff --git a/tests/Http/RequestTest.php b/tests/Http/RequestTest.php index db02b82a8..dced78bb4 100644 --- a/tests/Http/RequestTest.php +++ b/tests/Http/RequestTest.php @@ -694,7 +694,7 @@ public function testGetParsedBodyForm() $body = new RequestBody(); $body->write('foo=bar'); $request = new Request($method, $uri, $headers, $cookies, $serverParams, $body); - $this->assertEquals((object)['foo' => 'bar'], $request->getParsedBody()); + $this->assertEquals(['foo' => 'bar'], $request->getParsedBody()); } public function testGetParsedBodyJson() @@ -709,7 +709,7 @@ public function testGetParsedBodyJson() $body->write('{"foo":"bar"}'); $request = new Request($method, $uri, $headers, $cookies, $serverParams, $body); - $this->assertEquals((object)['foo' => 'bar'], $request->getParsedBody()); + $this->assertEquals(['foo' => 'bar'], $request->getParsedBody()); } public function testGetParsedBodyXml()