Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100925 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70447 invoked from network); 24 Oct 2017 08:43:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2017 08:43:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.163 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.163 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.163] ([81.169.146.163:19034] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EA/CE-58908-03DFEE95 for ; Tue, 24 Oct 2017 04:43:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1508834605; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=u59mI7NuWJS1BF1QVmrfV5a0lKunZHNdeOHPWIOYCAY=; b=B043zpBndJdsDqqCIiiDsL/bLCtIpSaQVht8+IrEes8P8PKE/eqNja6k/YSkwKXpSg jeLtGi/uLtmknJq9ddmGg3UgoVKub058CCi+brXPerRLuRUMDy7+L7WIHBq+9LvgiOkP JN7zsKIZz8FCQxMiNIvJVJJ3JvEB6T5WsvxaU= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mlsGbEv0XHBzMIJSS+jKTzde5mDb8Db2nURiu2cA== X-RZG-CLASS-ID: mo00 Received: by mail-yw0-f171.google.com with SMTP id z195so7945885ywz.6 for ; Tue, 24 Oct 2017 01:43:25 -0700 (PDT) X-Gm-Message-State: AMCzsaWqFhSFevutcMgxJ2POOrMzAEZYBk72r/Aiu/f4lg5un6JIf1pn oKLAdWSjfLwajqpZf2wuuz6OgrrUYdS8lrPK6mc= X-Google-Smtp-Source: ABhQp+RMOk8A1PYQ11/TDTJwpRKuUTAxFmeS4vdTEFKTbNSfZ5ACWm+SNHnhe9c96kzji97zXj/JYk+OT4zOWQCtuqU= X-Received: by 10.129.164.200 with SMTP id b191mr10898678ywh.1.1508834604768; Tue, 24 Oct 2017 01:43:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.37.130 with HTTP; Tue, 24 Oct 2017 01:43:24 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Oct 2017 10:43:24 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Stanislav Malyshev Cc: Sara Golemon , PHP internals Content-Type: multipart/alternative; boundary="94eb2c1295bea46577055c46ee70" Subject: Re: [PHP-DEV] json(Raw)Serializable? From: me@kelunik.com (Niklas Keller) --94eb2c1295bea46577055c46ee70 Content-Type: text/plain; charset="UTF-8" > > 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. > > Also, I'm not sure what is the case for fixed JSON serialization - cases > where the data is completely static and yet you still need to serialize > it is pretty rare IMHO. Yes, we save some cycles on serializing such > things, but how often that happens, really? If it's static, why not just > set it on loading? Maybe I miss some reasonable use case, but so far > sounds pretty exotic to me. Same thoughts here. Without further arguments I'd definitely vote against an RFC suggesting such a change. Regards, Niklas --94eb2c1295bea46577055c46ee70--