WordPress\AiClient\Common

AbstractDataTransferObject::jsonSerializepublicWP 0.1.0ReturnTypeWillChange

Converts the object to a JSON-serializable format.

This method uses the toArray() method and then processes the result based on the JSON schema to ensure proper object representation for empty arrays.

Method of the class: AbstractDataTransferObject{}

No Hooks.

Returns

Mixed. The JSON-serializable representation.

Usage

$AbstractDataTransferObject = new AbstractDataTransferObject();
$AbstractDataTransferObject->jsonSerialize();

Changelog

Since 0.1.0 Introduced.

AbstractDataTransferObject::jsonSerialize() code WP 7.0.2

public function jsonSerialize()
{
    $data = $this->toArray();
    $schema = static::getJsonSchema();
    return $this->convertEmptyArraysToObjects($data, $schema);
}