In the simplest cases type hinting should work:
$json = json_encode( (array)$object );
More Related Contents:
- Get a PHP object property that is a number [duplicate]
- How to convert a string to JSON object in PHP
- How to decode a JSON String with several objects in PHP?
- Access object property with disallowed character in property name
- Getting particular object
- How can I parse a JSON file with PHP? [duplicate]
- Reading JSON POST using PHP
- PHP Fatal error: Using $this when not in object context
- How to POST JSON Data With PHP cURL?
- json_decode returns NULL after webservice call
- Cannot use object of type stdClass as array?
- PHP json_encode encoding numbers as strings
- REST API – why use PUT DELETE POST GET?
- PHP json_decode() returns NULL with valid JSON?
- php json_encode not working on arrays partially
- ByetHost server passing html values “Checking your browser” with JSON String
- How can I access an object attribute that starts with a number?
- PHP check whether property exists in object or class
- Is there any way to convert json to xml in PHP?
- Is it possible to delete an object’s property in PHP?
- how to decode this JSON string?
- Adding subscribers to a list using Mailchimp’s API v3
- jQuery $.ajax request of dataType json will not retrieve data from PHP script
- How to pass an array using PHP & Ajax to Javascript?
- Accessing JSON array after json_decode/multidimensional array
- Find JSON strings in a string
- PHP json_encode json_decode UTF-8
- PHP: How to encode infinity or NaN numbers to JSON?
- json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT
- Laravel collection converts array to object