Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions en/views/json-and-xml-views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ customize the bit-mask used to generate JSON. See the
`json_encode <http://php.net/json_encode>`_ documentation for the valid
values of this option.

For example, to serialize validation error output of CakePHP entities in a consistent form of JSON do::

// In your controller's action when saving failed
$this->set('errors', $articles->errors());
$this->set('_jsonOptions', JSON_FORCE_OBJECT);
$this->set('_serialize', ['errors']);

JSONP Responses
---------------

Expand Down