json_decode
Decodes a JSON string into a PHP variable (object or array).
Parameters
main.php
Return Values
mixed
Returns the decoded value in appropriate PHP type
On success:PHP object/array representation of JSON data
On failure:null on error (use json_last_error() for details)
Notes
- Set associative=true to get arrays instead of objects
- Default depth limit is 512 to prevent infinite recursion
- Use JSON_THROW_ON_ERROR flag to throw exceptions instead of returning null
- Essential for API communication and data processing
Changelog
- 7.3.0: JSON_THROW_ON_ERROR flag added
- 7.2.0: associative parameter accepts null
Related Functions
json_encode
JSONReturns the JSON representation of a value. Used for serializing PHP data structures to JSON format.
jsonserializeapi