In the simplest cases type hinting should work:

$json = json_encode( (array)$object );