Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100936 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18895 invoked from network); 24 Oct 2017 17:16:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2017 17:16:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 212.232.28.122 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.28.122 mx201.easyname.com Received: from [212.232.28.122] ([212.232.28.122:33039] helo=mx201.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/A5-58908-D657FE95 for ; Tue, 24 Oct 2017 13:16:30 -0400 Received: from cable-81-173-135-10.netcologne.de ([81.173.135.10] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1e72oS-0001hk-Ba; Tue, 24 Oct 2017 17:16:27 +0000 Reply-To: internals@lists.php.net To: Sara Golemon , PHP internals References: Message-ID: <78b14ba9-d6c7-7a47-50bd-49aa5dc8c6ae@fleshgrinder.com> Date: Tue, 24 Oct 2017 19:16:05 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oOQfTxLQp2dnfN2uerg2Xbsq32jexhXqh" X-DNSBL-BARRACUDACENTRAL: YES X-DNSBL-PBLSPAMHAUS: YES Subject: Re: [PHP-DEV] json(Raw)Serializable? From: php@fleshgrinder.com (Fleshgrinder) --oOQfTxLQp2dnfN2uerg2Xbsq32jexhXqh Content-Type: multipart/mixed; boundary="gUMM6Fk52NFN1x0baMbCrlM8Nj79P9I7L"; protected-headers="v1" From: Fleshgrinder Reply-To: internals@lists.php.net To: Sara Golemon , PHP internals Message-ID: <78b14ba9-d6c7-7a47-50bd-49aa5dc8c6ae@fleshgrinder.com> Subject: Re: [PHP-DEV] json(Raw)Serializable? References: In-Reply-To: --gUMM6Fk52NFN1x0baMbCrlM8Nj79P9I7L Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 10/24/2017 2:20 AM, Sara Golemon wrote: > https://bugs.php.net/bug.php?id=3D75400 is asking for a version of > JsonSerializable which doesn't involve deserializing/reserialzing > round trips when a chunk of JSON is known in advance. >=20 > It's not terribly unreasonable IMO, but before I just writeup the RFC > as described (jsonRawSerialize taking preceedence over jsonSerialize), > I thought I'd ask for opinions on the specifics. >=20 > In psuedo-code: >=20 > if (is_object($obj)) { > if ($obj implements JsonRawSerializable) { > // use $obj->jsonRawSerialize() as is. > } elseif ($obj implements JsonSerializble) { > // use json_encode($obj->jsonSerialize()) > } else { > // Serialize the object's public properties as a key/value map > } > } >=20 > Perhaps with the stipulation that if jsonRawSerialize() returns null, > we'd fallback on jsonSerialize(). Any other non-string results in an > encoding error. >=20 > -Sara >=20 I agree with the others here. People often think that they can simply write the JSON on their own, but forget about the requirement for valid UTF-8 and other escaping and encoding stuff. It's better to simply not support it in the first place. --=20 Richard "Fleshgrinder" Fussenegger --gUMM6Fk52NFN1x0baMbCrlM8Nj79P9I7L-- --oOQfTxLQp2dnfN2uerg2Xbsq32jexhXqh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJZ73VbAAoJEOKkKcqFPVVriMIP/jctP+21GeT4MPQ/GMRJwDLU WjjaB6BN18uoRIclWNO0mbRZGrlx0gtmFv4PhpM0ZJTfZI2pIhedufqriuWoAO9D jIqBwJV9niMtFlX9+WdwxD55ADDk8q+1lYy2p8NDr36D9bXj90++Gk4wf9t+xTOO SrbhzUz1Sz1TMIa7B6e4G6zU3n1cVZTtyMwyIh02U/Q6Yfp4O22SXs30kX8MY/DZ cO6QxVt4CvFRL+WvhHDPBUHYBCPf7+FBE16WJS2XLxl8PJPycJLp29vUs6rj5FcT P3xM290HFNrwwwRHXG1Ojv9Hwn4mqQkvpQDCmVgATi0tjuuDx8jAOitgbcXwS3d1 lAFK+otamkMTzE7roUPIMP1T+n/oaFjIOTJqHiKN3WbumTJcH7PkGU0W49/GPZ+l wm6zd9s89X2OxFU+EDvWsXk7EQ4O0etnQe3C1Tv7Q6Bv88GLO2hMNEFPwRQkYFEk zn32eW/B+XAS+CFfXKOzq4ogaeugRgMW4nZKApXnJujnClU02a0w7qOwDrwe2g7O O9U21G2vMHepkdzPpXmzp6lOVha4qUbYhCPdrCW/4lrRne/kNsEoqOfzqMLrVH6u vI2AiL2hWYHVWn1tyR2EJ0s74u514qfa1vUDhXOd8eRlzhWcVleHqxQXF/kiIi3z EaHUW1l3TVao0q9J0mKU =ZxDL -----END PGP SIGNATURE----- --oOQfTxLQp2dnfN2uerg2Xbsq32jexhXqh--