Serializing PHP object to JSON July 10, 2022 by Tarik In the simplest cases type hinting should work: $json = json_encode( (array)$object );