Skip to content

Commit

Permalink
add _jsonOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
slywalker committed Nov 20, 2013
1 parent 86f08c9 commit 03aa24f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Cake/View/JsonView.php
Expand Up @@ -146,11 +146,16 @@ protected function _serialize($serialize) {
$data = isset($this->viewVars[$serialize]) ? $this->viewVars[$serialize] : null;
}

$jsonOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;
if (isset($this->viewVars['_jsonOptions'])) {
$jsonOptions = $this->viewVars['_jsonOptions'];
}

if (Configure::read('debug')) {
return json_encode($data, JSON_PRETTY_PRINT);
return json_encode($data, $jsonOptions | JSON_PRETTY_PRINT);
}

return json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
return json_encode($data, $jsonOptions);
}

}

0 comments on commit 03aa24f

Please sign in to comment.