title: json_encode() expects parameter 2 to be long, string given
body: <p>I'm trying to return a JSON from a REST Service using this code:</p>
  
  <pre><code>$categories = $categoriesController-&gt;listAll();
  if($categories){
     header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
     header("Content-Type: application/json");
     echo json_encode($categories,JSON_PRETTY_PRINT);
  }else{
  
  }
  </code></pre>
  
  <p>But I get this error:</p>
  
  <blockquote>
    <p>json_encode() expects parameter 2 to be long, string given</p>
  </blockquote>
  
  <p>I've seen several examples use the exact same code so I don't understand why i'm getting this issue. I'd appreciate some help with this problem. Thanks :)</p>