note 126111 added to function.json-encode

From: Date: Wed, 26 May 2021 08:52:16 +0000
Subject: note 126111 added to function.json-encode
Groups: php.notes 
Request: Send a blank email to php-notes+get-216430@lists.php.net to get a copy of this message
Notice that <?php $json = json_encode($x, JSON_FORCE_OBJECT); ?> doesn't guarantee that $json is actually an object encoded with JSON syntax. It *only* guarantees that the output doesn't start with "[". For example: <?php json_encode("foo", JSON_FORCE_OBJECT); # "foo" json_encode(42, JSON_FORCE_OBJECT); # 42 json_encode(false, JSON_FORCE_OBJECT); # false json_encode("false", JSON_FORCE_OBJECT); # "false" json_encode(10/3, JSON_FORCE_OBJECT); # 3.3333333333333335 ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 84.251.221.37) ---- Manual Page -- https://php.net/manual/en/function.json-encode.php Edit -- https://main.php.net/note/edit/126111 Del: integrated -- https://main.php.net/note/delete/126111/integrated Del: useless -- https://main.php.net/note/delete/126111/useless Del: bad code -- https://main.php.net/note/delete/126111/bad+code Del: spam -- https://main.php.net/note/delete/126111/spam Del: non-english -- https://main.php.net/note/delete/126111/non-english Del: in docs -- https://main.php.net/note/delete/126111/in+docs Del: other reasons-- https://main.php.net/note/delete/126111 Reject -- https://main.php.net/note/reject/126111 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216430) next »