XML::jsonSerialize()

Returns the data to be serialized as JSON.

Table of Contents
  1. Description
  2. Example

Description

XML::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 XML('<svg version="1.1"></svg>');

$test = json_encode($node); // Returns `'["svg","",{"version":"1.1"}]'`

XML::jsonSerialize()

Returns the data to be serialized as JSON.