<?php

namespace SlimJson;

use Slim\Slim;

class View extends \Slim\View {

  /**
   * @param int|string $status
   * @param array|null $data
   * @return void
   */
  public function render($status, $data = null)
  {
    $app = Slim::getInstance();
    $response = $this->all();

    $status = \intval($status);
    $app->response()->status($status);
    if ($app->config(Config::Status)) {
      $response['_status'] = $status;
    }

    if (isset($response['flash']) && \is_object($response['flash'])) {
      $flash = $this->data->flash->getMessages();
      if (count($flash)) {
        $response['flash'] = $flash;
      } else {
        unset($response['flash']);
      }
    }

    $app->response()->header('Content-Type', 'application/json');
    $body = json_encode($response, $app->config(Config::JsonEncodeOptions));
    if($status == 404){
        return $body;
    }else{
        $app->response()->body($body);
    }
 }
}

<?php

namespace SlimJson;

use Slim\Slim;

class View extends \Slim\View {

  /**
   * @param int|string $status
   * @param array|null $data
   * @return void
   */
  public function render($status, $data = null)
  {
    $app = Slim::getInstance();
    $response = $this->all();

    $status = \intval($status);
    $app->response()->status($status);
    if ($app->config(Config::Status)) {
      $response['_status'] = $status;
    }

    if (isset($response['flash']) && \is_object($response['flash'])) {
      $flash = $this->data->flash->getMessages();
      if (count($flash)) {
        $response['flash'] = $flash;
      } else {
        unset($response['flash']);
      }
    }

    $app->response()->header('Content-Type', 'application/json');
    $body = json_encode($response, $app->config(Config::JsonEncodeOptions)));
    if($status == 404){
        return $body;
    }else{
        $app->response()->body($body);
    }

}

--- 
+++ 
@@ -32,11 +32,11 @@
     }
 
     $app->response()->header('Content-Type', 'application/json');
-    $body = json_encode($response, $app->config(Config::JsonEncodeOptions)));
+    $body = json_encode($response, $app->config(Config::JsonEncodeOptions));
     if($status == 404){
         return $body;
     }else{
         $app->response()->body($body);
     }
-
+ }
 }
Fix render function so 404 body is not ignored by slim
