Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

Updated default Json::decode type #1358

Merged
merged 1 commit into from
Oct 16, 2014
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
10 changes: 5 additions & 5 deletions docs/languages/en/modules/zend.json.objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ to *PHP*'s associative array. Some suggest that a class identifier should be pas
class should be created and populated with the key/value pairs of the *JSON* object; others feel this could pose a
substantial security risk.

By default, ``Zend\Json\Json`` will decode *JSON* objects as associative arrays. However, if you desire an object
returned, you can specify this:
By default, ``Zend\Json\Json`` will decode *JSON* objects as ``stdClass`` objects. However, if you desire an
associative array returned, you can specify this:

.. code-block:: php
:linenos:

// Decode JSON objects as PHP objects
$phpNative = Zend\Json\Json::decode($encodedValue, Zend\Json\Json::TYPE_OBJECT);
// Decode JSON objects as PHP array
$phpNative = Zend\Json\Json::decode($encodedValue, Zend\Json\Json::TYPE_ARRAY);

Any objects thus decoded are returned as ``stdClass`` objects with properties corresponding to the key/value pairs
Any objects thus decoded are returned as associative arrays with keys and values corresponding to the key/value pairs
in the *JSON* notation.

The recommendation of Zend Framework is that the individual developer should decide how to decode *JSON* objects.
Expand Down