Fully Qualified Name: | Laminas\Json\Json |
Class for encoding to and decoding from JSON.
Name | Description | Defined By |
---|---|---|
decode() | Decodes the given $encodedValue string from JSON. | Json |
encode() | Encode the mixed $valueToEncode into the JSON format | Json |
prettyPrint() | Pretty-print JSON string | Json |
Decodes the given $encodedValue string from JSON.
Uses json_decode() from ext/json if available.
Parameter Name | Type | Description |
---|---|---|
$encodedValue | string | Encoded |
$objectDecodeType | int | Optional; |
Returns: mixed
Encode the mixed $valueToEncode into the JSON format
Encodes using ext/json's json_encode() if available.
NOTE: Object should not contain cycles; the JSON format does not allow object reference.
NOTE: Only public variables will be encoded
NOTE: Encoding native javascript expressions are possible using Laminas\Json\Expr.
You can enable this by setting $options['enableJsonExprFinder'] = true
Parameter Name | Type | Description |
---|---|---|
$valueToEncode | mixed | |
$cycleCheck | bool | Optional; |
$options | array | Additional |
Returns: string JSON encoded object
Pretty-print JSON string
Use 'indent' option to select indentation string; by default, four spaces are used.
Parameter Name | Type | Description |
---|---|---|
$json | string | Original |
$options | array | Encoding |
Returns: string