Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
JSONCodec Class Reference
+ Collaboration diagram for JSONCodec:

Public Member Functions

 decode ($json, $assoc=false, $depth=512)
 
 encode ($value, $options=0)
 

Detailed Description

The JSONCodec class simplify JSON encoding/decoding errors handling by throwing Dcp, with corresponding JSON error constant, instead of returning null on errors (which could be mistaken with valid JSON null values for example).

Definition at line 12 of file Class.JSONCodec.php.

Member Function Documentation

decode (   $json,
  $assoc = false,
  $depth = 512 
)

Decode JSON string

Parameters
string$jsonsee $json from PHP's json_decode()
bool$assocsee $assoc from PHP's json_decode()
int$depthsee $depth from PHP's json_decode()
Returns
mixed|null returns the resulting PHP structure
Exceptions
Dcp\ExceptionException is throwned on error

Definition at line 24 of file Class.JSONCodec.php.

encode (   $value,
  $options = 0 
)

Encode value into JSON string

Parameters
mixed$valuesee $value from PHP's json_encode()
int$optionssee $options from PHP's json_encode()
Returns
string returnes the resulting JSON string
Exceptions
Dcp\ExceptionException is throwned on error

Definition at line 48 of file Class.JSONCodec.php.


The documentation for this class was generated from the following file:
← centre documentaire © anakeen