HTML::jsonSerialize()

Returns the data to be serialized as JSON.

Table of Contents
  1. Description
  2. Example

Description

HTML::jsonSerialize(): mixed;

This method is a requirement to be able to implement the JsonSerializable interface and aims to make the data convertable to JSON. You won’t use this method directly, the json_encode() function will call this method automatically.

Example

$node = new HTML('<div></div>');

echo json_encode($node); // Returns `'["div","",{}]'`

HTML::jsonSerialize()

Returns the data to be serialized as JSON.