protected function jsonify($data)
    {
        // JSON_NUMERIC_CHECK removes leading zeros
        // which is an issue in cases like postcode e.g. 00160
        // see https://bugs.php.net/bug.php?id=64695
        $json = json_encode($data);

        //catch JSON parsing error
        $error = RESTfulAPIError::get_json_error();
        if ($error !== false) {
            return new RESTfulAPIError(400, $error);
        }

        return $json;
    }