Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100933 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1816 invoked from network); 24 Oct 2017 14:06:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2017 14:06:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.180 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.161.180 mail-yw0-f180.google.com Received: from [209.85.161.180] ([209.85.161.180:51117] helo=mail-yw0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B4/53-58908-5F84FE95 for ; Tue, 24 Oct 2017 10:06:46 -0400 Received: by mail-yw0-f180.google.com with SMTP id i198so15163028ywe.7 for ; Tue, 24 Oct 2017 07:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=MRLk0svX8HiPh8SRO/7gSEbPdqxzUzhvLplYRHAlTK0=; b=UL5GcSUMdT8Skddn1Pa5LbOeaKSyU+yvVOG+JZqF8wq7KC3WhdHp6MKr9s94zJGs/Y Cmu2Ym7JEB9Jbhfki2AW6ldZKLXr+TF+iQ79cpgRgzJ9esPm/da8pyvREG5leegSFJd7 fB0seLslybEl1WIJniZlRQ3i7wJsxeWSjXXUhxWV/pW47tOE+x2GbjasbSzIeoFX+OHv ydi7REQayrtxFSOceyKUVXmKpkl7YzNgJ1rtaJv2hSxidAcbHj3/2eroxTKOXwPUAORg gWH7A1xieM/BB2DlTRMMxwOYZ39OW67X/STRYyhuvrHbKSzv5nQszvuTUmoWTXUDri/k 2JhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=MRLk0svX8HiPh8SRO/7gSEbPdqxzUzhvLplYRHAlTK0=; b=WsF2hN/Igrs+uiOI58P2lzZ2e9MUUyHlevHUj9Z+5Czv/GbmTWwb0oHZk8/zHXgX3C FTAO2mZQc5UJS73DjFmYPGb2hXRjh9MC3ii4YBjQMofi8ESU98p4NJiW4C3OwGNO5fRD fg6s3bE+xX2vt1OD5ScrPYLKKDm/R5W244ghCs51ny0vrXIP44WFXf4CxuhCklBzEWmF hVygXHLt6gz1aJtVdsJzet2sZ/xhJGqVzloQBi7UK5aAd0dkpI0dCEKjEe1yl6O3YeSh U6gZ0CjmpEDTV3HB/yK+L1dgQ5TPT0qudqJ6XjbiaZ5a2ndeflMMaBT0g30Y8hFSW98k JKDA== X-Gm-Message-State: AMCzsaUK4ZbmeI0wd15T0D8uV8BtvUqxYpLT73BmoCZI9C1v8Trgpi0+ op87vC6yoyVPVUNvsV9AUwC/asOeCtLVBQlO0nQ= X-Google-Smtp-Source: ABhQp+SgBhOnNqeJElNUGOUD93JqBcysL5G+hGb+B0o1AfVsGLX7+RKGGwcBZGbIzXRF2lHY3U89RSJGA3/QjqenQoc= X-Received: by 10.37.104.4 with SMTP id d4mr10708828ybc.282.1508854003304; Tue, 24 Oct 2017 07:06:43 -0700 (PDT) MIME-Version: 1.0 Sender: jakub.php@gmail.com Received: by 10.129.92.196 with HTTP; Tue, 24 Oct 2017 07:06:42 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Oct 2017 15:06:42 +0100 X-Google-Sender-Auth: ZJBQPQdFtE8nlAANeIAcjx7hYyw Message-ID: To: Stanislav Malyshev Cc: Sara Golemon , PHP internals Content-Type: multipart/alternative; boundary="f403045c03bae2a80d055c4b72b3" Subject: Re: [PHP-DEV] json(Raw)Serializable? From: bukka@php.net (Jakub Zelenka) --f403045c03bae2a80d055c4b72b3 Content-Type: text/plain; charset="UTF-8" On Tue, Oct 24, 2017 at 7:32 AM, Stanislav Malyshev wrote: > Hi! > > > 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. > > > > In psuedo-code: > > > > 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 > > } > > } > > I'm not sure I feel very comfortable with having specialized serialize > interfaces for every format, yet more with having more than one of them. > > There's also validation problem - if we don't ensure this is valid JSON, > then whole serialization setup is broken, and who knows which > consequences this will bring. > > I fully agree with this. In addition to validation we wouldn't be able to assure that options work as well. For example consider options like JSON_HEX_*, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT, JSON_PRESERVE_ZERO_FRACTION, JSON_UNESCAPED_UNICODE and some other encode options. I think this is not a good idea and can cause many problems. So -1 from me. Cheers Jakub --f403045c03bae2a80d055c4b72b3--