php / 8.1.5 / class.jsonserializable.html /

The JsonSerializable interface

Introduction

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

Objects implementing JsonSerializable can customize their JSON representation when encoded with json_encode().

Interface synopsis

interface JsonSerializable {
/* Methods */
public jsonSerialize(): mixed
}

Table of Contents

© 1997–2021 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/class.jsonserializable.php