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

From: Date: Wed, 06 Nov 2019 09:25:07 +0000
Subject: Req #78786 [NEW]: json_encode should have an option to disallow objects
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223594@lists.php.net to get a copy of this message
From:             andre at webkr dot de
Operating system: 
PHP version:      7.3.11
Package:          Unknown/Other Function
Bug Type:         Feature/Change Request
Bug description:json_encode should have an option to disallow objects

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 bug report at https://bugs.php.net/bug.php?id=78786&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=78786&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=78786&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=78786&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=78786&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=78786&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=78786&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=78786&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=78786&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=78786&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=78786&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78786&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=78786&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=78786&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=78786&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=78786&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=78786&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=78786&r=mysqlcfg


Thread (3 messages)

« previous php.bugs (#223594) next »