Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100923 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27912 invoked from network); 24 Oct 2017 06:32:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2017 06:32:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.54 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 74.125.83.54 mail-pg0-f54.google.com Received: from [74.125.83.54] ([74.125.83.54:51470] helo=mail-pg0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/A6-58908-19EDEE95 for ; Tue, 24 Oct 2017 02:32:50 -0400 Received: by mail-pg0-f54.google.com with SMTP id p9so13727631pgc.8 for ; Mon, 23 Oct 2017 23:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=xQLiJzRVdyrWV8cYJch7nW4IFwYWxAFMedzpTQgV9ag=; b=NOwibK/il9A8kff16+J6jOxKuHoilv42xPkL6hv7QWaNmkfMJVe2GWKhLRCKKcYeue S4SwD6VjfSGLFOMuVmG88gQ5xJRYWbR/9bJpvFeAay/tkp0snKCYTfkP52jRhn9pcodg LYmd2cmRKdNS+yJ/u/HgaSaxBBBXK5WHrKHk2Aw6YRFJlJ3So56Q/mD5d8VIkM6FwRBW xjj/vMaBBP3/gppefa6dlQKK4260Z+rmjp40D2VBxaSu4DrsTtF7T3uW5bqV1wO5Iz5b h6oCaqJvd6l2yaAjCgwaJKjksYoqkveaKyrlhcb5felgDAc8Ub27OAysnvwD2061Guun O4Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xQLiJzRVdyrWV8cYJch7nW4IFwYWxAFMedzpTQgV9ag=; b=aT4UaWzgvUhtTR5+uaen9bv++nsyBTnfXSm+R5D3RST+d4YJ6HlafogL5WEW0LGazP arw9KBIj+dd0TX2tX0DINFo3QmUuo5WBlIBAEd7W8MHljEPrGngjPjInix0GeBbTpfZ9 zJDa0iXX9LgIpRkv5+wVsdkF06gyn8ePra5MhsevXPiumINBmDzXAXCLGHPd3oN7GEHK 4UcpL2HtzuhGdxo7iK2UmLEY7qIBGz86/Kc4vLhrklWT+rS4lz3HFlB9vbvhq0Mem4Bs BgNeuS9Q3BAcaWfu38THedoVAxsLHlc6ZOCzN0N/r7g78v4+6lLvoAfUAW291yyuVtRs gkaw== X-Gm-Message-State: AMCzsaU+Gak5RJZ7XNeTv5NSZJdjS9Fv1iz/yaXdZ7aidew7v96b+QNS t+KVnYkKZUDB0J/JeOZ4mpGfCD4= X-Google-Smtp-Source: ABhQp+Sdl1cr8wLTpVIqFcLqAWnrHyDv/qrm5QiYZun6EFQPgMLg9O/AZw8wu3V7ICZB1xapAjdgEQ== X-Received: by 10.98.67.154 with SMTP id l26mr15538851pfi.212.1508826765975; Mon, 23 Oct 2017 23:32:45 -0700 (PDT) Received: from Stas-Pro-2016.local (c-73-71-144-171.hsd1.ca.comcast.net. [73.71.144.171]) by smtp.gmail.com with ESMTPSA id e24sm16051357pfl.43.2017.10.23.23.32.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 23:32:45 -0700 (PDT) To: Sara Golemon , PHP internals References: Message-ID: Date: Mon, 23 Oct 2017 23:32:44 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] json(Raw)Serializable? From: smalyshev@gmail.com (Stanislav Malyshev) 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. -- Stas Malyshev smalyshev@gmail.com