[master] Better documentation for
This commit is contained in:
parent
ea79360fba
commit
b1e14b27ba
@ -25,12 +25,16 @@ interface DecoderInterface
|
|||||||
* @param string $format Format name
|
* @param string $format Format name
|
||||||
* @param array $context options that decoders have access to.
|
* @param array $context options that decoders have access to.
|
||||||
*
|
*
|
||||||
|
* The format parameter specifies which format the data is in; valid values depend on the specific implementation.
|
||||||
|
* Authors implementing this interface are encouraged to document which formats they support in a non-inherited
|
||||||
|
* phpdoc comment.
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function decode($data, $format, array $context = array());
|
public function decode($data, $format, array $context = array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the serializer can decode from given format
|
* Checks whether the deserializer can decode from given format
|
||||||
*
|
*
|
||||||
* @param string $format format name
|
* @param string $format format name
|
||||||
*
|
*
|
||||||
|
@ -18,15 +18,31 @@ namespace Symfony\Component\Serializer\Encoder;
|
|||||||
*/
|
*/
|
||||||
class JsonDecode implements DecoderInterface
|
class JsonDecode implements DecoderInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Specifies if the returned result should be an associative array or a nested stdClass object hierarchy
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
private $associative;
|
private $associative;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the recursion depth
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
private $recursionDepth;
|
private $recursionDepth;
|
||||||
|
|
||||||
private $lastError = JSON_ERROR_NONE;
|
private $lastError = JSON_ERROR_NONE;
|
||||||
protected $serializer;
|
protected $serializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new JsonDecode instance.
|
||||||
|
*
|
||||||
|
* @param bool $associative True to return the result associative array, false for a nested stdClass hierarchy.
|
||||||
|
* @param int $depth Specifies the recursion depth
|
||||||
|
*/
|
||||||
public function __construct($associative = false, $depth = 512)
|
public function __construct($associative = false, $depth = 512)
|
||||||
{
|
{
|
||||||
$this->associative = $associative;
|
$this->associative = $associative;
|
||||||
$this->recursionDepth = $depth;
|
$this->recursionDepth = (int)$depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,12 +58,27 @@ class JsonDecode implements DecoderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes a JSON string into PHP data
|
* @param string $data The encoded JSON string to decode
|
||||||
|
* @param string $format Must be set to JsonEncoder::FORMAT
|
||||||
|
* @param array $context An optional set of options for the JSON decoder; see below.
|
||||||
*
|
*
|
||||||
* @param string $data JSON
|
* The $context array is a simple key=>value array, with the following supported keys:
|
||||||
* @param string $format
|
*
|
||||||
|
* json_decode_associative: boolean
|
||||||
|
* If true, returns the object as associative array.
|
||||||
|
* If false, returns the object as nested StdClass
|
||||||
|
* If not specified, this method will use the default set in JsonDecode::__construct
|
||||||
|
*
|
||||||
|
* json_decode_recursion_depth: integer
|
||||||
|
* Specifies the maximum recursion depth
|
||||||
|
* If not specified, this method will use the default set in JsonDecode::__construct
|
||||||
|
*
|
||||||
|
* json_decode_options: integer
|
||||||
|
* Specifies additional options as per documentation for json_decode. Only supported with PHP 5.4.0 and higher.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @see http://php.net/json_decode json_decode
|
||||||
*/
|
*/
|
||||||
public function decode($data, $format, array $context = array())
|
public function decode($data, $format, array $context = array())
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user