Req #75400 [Ana->Sus]: Already As JSON

From: Date: Thu, 22 Apr 2021 11:31:31 +0000
Subject: Req #75400 [Ana->Sus]: Already As JSON
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233553@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75400&edit=1 ID: 75400 Updated by: cmb@php.net Reported by: jwalton at aretehs dot com Summary: Already As JSON -Status: Analyzed +Status: Suspended Type: Feature/Change Request Package: JSON related Operating System: Any PHP Version: 7.0.24 Assigned To: pollita Block user comment: N Private report: N New Comment: Hmm, seems this has stalled, and according to the discussion would need an RFC. If anybody is still interested in this feature, please pursue the RFC process[1]. For the time being, I suspend this ticket. > Because sending messages to the mailing list get rejected. I don't know whether the subscription form is still broken, but you can manually subscribe by sending a mail to mailinglist-subscribe@example.org See the EZML docs[2] for further details. [1] <https://wiki.php.net/rfc/howto> [2] <http://untroubled.org/ezmlm/ezman/ezman1.html#ss1.2> Previous Comments: ------------------------------------------------------------------------ [2017-11-06 21:24:49] jwalton at aretehs dot com Because sending messages to the mailing list get rejected. And there is no way to register or sign up to get access. And before you point me to the main mailing list page, the subscribe/unsubscribe buttons do not do anything. I've put in 4 different email addresses across 3 providers, and 2 weeks later, still no confirmation emails. ------------------------------------------------------------------------ [2017-10-26 08:56:55] spam2 at rhsoft dot net which permissions? it's just a mailing list like any other where you can subscribe ------------------------------------------------------------------------ [2017-10-26 02:34:17] jwalton at aretehs dot com I would, but I don't have permissions to put anything in that mail list. ------------------------------------------------------------------------ [2017-10-25 14:37:57] pollita@php.net As you've seen, the pushback is pretty strong atm, would you mind presenting your case on internals directly? ------------------------------------------------------------------------ [2017-10-25 00:45:46] jwalton at aretehs dot com So, surprisingly, unlike other PHP code (that I wouldn't touch with a 10 foot pole) the ext/json was surprisingly clean. I was able to add this functionality in myself in 15 mins. Tested it on one of my website and wow, what an increase in performance. Added JsonRawSerialize but I changed the function name to jsonSerialized (past tense). Same performance script (but done on a different machine) <?php $jsondata = file_get_contents("test.json"); $jd = json_decode($jsondata); class Test implements JsonRawSerializable { public $str; function __construct(&$str) { $this->str = $str; } function jsonSerialized() { return $this->str; } } $jrs = new Test($jsondata); function timing($func, $iter) { $stime = microtime(true); for($counter=1;$counter<$iter;$counter++) { $func(); } $etime = microtime(true); return $etime - $stime; } function json_decenc() { global $jsondata; $data = json_encode((object)[ "result" => json_decode($jsondata) ]); } function json_enc() { global $jd; $data = json_encode((object)[ "result" => $jd ]); } function json_str() { global $jsondata; $data = '{"result":'.$jsondata.'}'; } function json_raw() { global $jrs; $data = json_encode([ "result" => $jrs ]); } print "json_decenc = ".timing('json_decenc', 10000)."\n"; print "json_enc = ".timing('json_enc', 10000)."\n"; print "json_str = ".timing('json_str', 10000)."\n"; print "json_raw = ".timing('json_raw', 10000)."\n"; gave me json_decenc = 35.672137975693 json_enc = 14.386140823364 json_str = 0.11590504646301 json_raw = 0.35667610168457 only ~twice as slow as string concat, 99 times faster than decode(encode()), and its even faster than just re-encoding the same object. Unfortunately, the pure php json decoder/encoder doesn't hold a candle to the C one. To bad its not built in. All I did was check the return value Z_TYPE() == IS_STRING and then pass that directly to the smart_str_appendl() (saw that it was used for smart_str_appendl(buf, "true", 4); -> smart_str_appendl(buf, Z_STRVAL(retval), Z_STRLEN(retval)); I have a patch if anyone is interested. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=75400 -- Edit this bug report at https://bugs.php.net/bug.php?id=75400&edit=1

« previous php.bugs (#233553) next »