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