HumHub Documentation (unofficial)

JsonExpression
in package
implements ExpressionInterface, JsonSerializable

Class JsonExpression represents data that should be encoded to JSON.

For example:

new JsonExpression(['a' => 1, 'b' => 2]); // will be encoded to '{"a": 1, "b": 2}'
Tags
author

Dmytro Naumenko d.naumenko.a@gmail.com

since
2.0.14

Table of Contents

Interfaces

ExpressionInterface
Interface ExpressionInterface should be used to mark classes, that should be built in a special way.
JsonSerializable

Constants

TYPE_JSON  = 'json'
TYPE_JSONB  = 'jsonb'

Properties

$type  : string|null
$value  : mixed

Methods

__construct()  : mixed
JsonExpression constructor.
getType()  : string|null
getValue()  : mixed
jsonSerialize()  : mixed
Specify data which should be serialized to JSON

Constants

Properties

$type

protected string|null $type

Type of JSON, expression should be casted to. Defaults to null, meaning no explicit casting will be performed. This property will be encountered only for DBMSs that support different types of JSON. For example, PostgreSQL has json and jsonb types.

$value

protected mixed $value

the value to be encoded to JSON. The value must be compatible with [\yii\helpers\Json::encode()|Json::encode()]] input requirements.

Methods

__construct()

JsonExpression constructor.

public __construct(mixed $value[, string|null $type = null ]) : mixed
Parameters
$value : mixed

the value to be encoded to JSON. The value must be compatible with [\yii\helpers\Json::encode()|Json::encode()]] requirements.

$type : string|null = null

the type of the JSON. See [[JsonExpression::type]]

Tags
see
type

getType()

public getType() : string|null
Tags
see
type
Return values
string|null

the type of JSON


        
On this page

Search results