title: json_decode() expecting a string, I could only get an array
body: <p>I'm using <em>Slim Framework</em>, trying to build a <em>REST API</em>. Long story short, I've been like for 4 hours looking for a solution for my problem, which it is that json_decode won't take as an argument the array that getBody() returns.</p>
  
  <p>Using <em>Advanced REST Client for Chrome</em>, the error I get when I do a <strong>post request</strong> is:</p>
  
  <pre><code>Slim Application Error
  The application could not run because of the following error:
  
  Details
  
  Type: ErrorException
  Code: 2
  Message: json_decode() expects parameter 1 to be string, array given
  File: C:\xampp\htdocs\farmacias\index.php
  Line: 100
  Trace
  
  #0 [internal function]: Slim\Slim::handleErrors(2, 'json_decode() e...', 'C:\xampp\htdocs...', 100, Array)
  #1 C:\xampp\htdocs\farmacias\index.php(100): json_decode(Array)
  #2 [internal function]: {closure}()
  #3 C:\xampp\htdocs\farmacias\Slim\Router.php(172): call_user_func_array(Object(Closure), Array)
  #4 C:\xampp\htdocs\farmacias\Slim\Slim.php(1222): Slim\Router-&gt;dispatch(Object(Slim\Route))
  #5 C:\xampp\htdocs\farmacias\Slim\Middleware\Flash.php(86): Slim\Slim-&gt;call()
  #6 C:\xampp\htdocs\farmacias\Slim\Middleware\MethodOverride.php(94): Slim\Middleware\Flash-&gt;call()
  #7 C:\xampp\htdocs\farmacias\Slim\Middleware\ContentTypes.php(80): Slim\Middleware\MethodOverride-&gt;call()
  #8 C:\xampp\htdocs\farmacias\Slim\Middleware\PrettyExceptions.php(67): Slim\Middleware\ContentTypes-&gt;call()
  #9 C:\xampp\htdocs\farmacias\Slim\Slim.php(1174): Slim\Middleware\PrettyExceptions-&gt;call()
  #10 C:\xampp\htdocs\farmacias\index.php(139): Slim\Slim-&gt;run()
  #11 {main}
  </code></pre>
  
  <p>And my <strong>piece of code</strong>, being the line 100 the one with json_decode on it</p>
  
  <pre><code>// POST /localidades
  $app-&gt;post('/localidades', function () use ($app){
      // Obtenemos el cuerpo del request, y lo decodificamos
      $request = $app-&gt;request();
      $body = $request-&gt;getBody();
      $input = json_decode($body);
  
      // Creamos y guardamos el registro
      $eloc = R::dispense('localidades');
      $eloc-&gt;nombre = (string)$input-&gt;nombre;
      $eloc-&gt;provincia = (string)$input-&gt;provincia;
      R::store($eloc);
  
      // Creamos y devolvemos JSON
      $app-&gt;response()-&gt;status(201);
      $app-&gt;response()-&gt;header('Content-Type','application/json');
      echo json_encode(R::exportAll($eloc));
  
  });
  </code></pre>
  
  <p>If anyone could help me, I would be delighted. Of course I would also like to know if I'm doing something wrong or approaching the wrong way. I spend a lot of time looking for an answer and I couldn't find any.</p>