Req #78786 [Com]: json_encode should have an option to disallow objects

From: Date: Fri, 02 Jun 2023 10:07:52 +0000
Subject: Req #78786 [Com]: json_encode should have an option to disallow objects
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244590@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78786&edit=1 ID: 78786 Comment by: hydtwuegiu32 at gmail dot com Reported by: andre at webkr dot de Summary: json_encode should have an option to disallow objects Status: Open Type: Feature/Change Request Package: JSON related PHP Version: 7.3.11 Block user comment: N Private report: N New Comment: I need that type of things.(https://www.ballsportspro.com/)github.com Previous Comments: ------------------------------------------------------------------------ [2019-11-13 19:23:38] henry dot paradiz at gmail dot com Agreed. ------------------------------------------------------------------------ [2019-11-06 09:25:07] andre at webkr dot de Description: ------------ json_encode() encodes an object by treating its public properties like an array. This is not always the desired behavior and it's difficult to detect beforehand without walking the whole input array. Therefore it would be good if json_encode() had an option to make it refuse to encode any object (throw an exception), unless the object implements JsonSerializable. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78786&edit=1

« previous php.bugs (#244590) next »