You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Safely converts a valid JSON string into a native PHP object.
Usage
jsonToObject(string $json): array|object
Parameters
json (string)
: The JSON string to decode and convert into an object.
Return Value
(array|object)
: Returns a PHP object (or array depending on the structure) on success.
: Returns an empty array ([]) if the JSON string is malformed or decodes into a non-array scalar value.
📌 Chains jsonToArray and arrayToObject to safely handle invalid JSON payloads without throwing uncaught exceptions.