Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118196 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 10356 invoked from network); 5 Jul 2022 07:46:15 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jul 2022 07:46:15 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BA16B180548 for ; Tue, 5 Jul 2022 02:38:58 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 5 Jul 2022 02:38:58 -0700 (PDT) Received: by mail-ed1-f53.google.com with SMTP id x10so7170421edd.13 for ; Tue, 05 Jul 2022 02:38:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=A2tF3n39s6xeT7fBzwtTOcTMPzPx5H/mT4Jt5oB1svE=; b=TctvOE/Ih6dNZN9j0/EpAExZYutziTvfcvxNZlJI5Wul4CuNbDtW4GPOrYTk7+3BVi dOqxYGyEbNCK5ibGGbUbFVG0gGS4MNkUj1n1B4tQEeXz/QTARYYSf4jvvtZYNd251GsN svMWhsFrii2ivaX1MVeg5qidxsZ2eJ5f9MCksuNDM86mTL0YR/oiRUyS1Ts0+U5BasI8 LQP5AmVToQ85ELsGMAutech6zXwJ+SqAHfSli3KNZZs0qwzCH9Tc+5TN0KC6qYeeEN99 FjkVbyk6iE+1UAJqk+FzJpiRsSK/FIIXgNktnBXlqh/JZaojKUXsPjGBKwdwflFlGEx9 DvDw== X-Gm-Message-State: AJIora+QVzT5Yg6rxAIvMmgauHMDFVDvz/mNtGAOrIohteHX8q8Snt2l tcmpS6h8dd64TY/xvX/6eOqylmYQNKUTe6ZCWbUYZlG1 X-Google-Smtp-Source: AGRyM1tyT5nUINLblsGiSFFkV00VvawyD/uW3zIXtQrS2Pkn9pgUGfoesgUipR2ldmyu8vYmwTBDpPRUAm5MU78xQl0= X-Received: by 2002:a05:6402:330d:b0:435:95ae:9b1e with SMTP id e13-20020a056402330d00b0043595ae9b1emr43884688eda.402.1657013937033; Tue, 05 Jul 2022 02:38:57 -0700 (PDT) MIME-Version: 1.0 References: <7d72b5c1-d19b-8734-57e0-f02c402b09c2@gmail.com> <64e73280-83aa-c60d-4c01-54a617c5468f@gmail.com> <8fd7bed5-2392-dec2-27d4-f2055e7021f1@heigl.org> In-Reply-To: <8fd7bed5-2392-dec2-27d4-f2055e7021f1@heigl.org> Date: Tue, 5 Jul 2022 10:38:46 +0100 Message-ID: To: Andreas Heigl Cc: PHP internals list Content-Type: multipart/alternative; boundary="0000000000001ad58605e30b9fbe" Subject: Re: [PHP-DEV] [RFC] Add json_encode indent parameter From: bukka@php.net (Jakub Zelenka) --0000000000001ad58605e30b9fbe Content-Type: text/plain; charset="UTF-8" On Tue, Jul 5, 2022 at 8:37 AM Andreas Heigl wrote: > Hey all. > > On 05.07.22 02:04, Peter Cowburn wrote: > > On Mon, 4 Jul 2022 at 11:11, Jakub Zelenka wrote: > > > >> On Mon, Jul 4, 2022 at 8:38 AM Timon de Groot > >> wrote: > >> > >>> Hi internals, > >>> > >>> If the rest also thinks the RFC is good to go, I suggest we start a > vote > >>> coming week. > >>> As this is my first RFC, I'm not so sure how this typically gets kicked > >>> off, so I'd like to know what I need to do! > >>> > >> > >> You just need to change status in RFC to Voting and in voting section > set > >> the date range and add doodle poll - you can basically copy it from one > of > >> the open RFC's (see for example code in > >> https://wiki.php.net/rfc/fetch_property_in_const_expressions ). Then > you > >> just need to send email to internals with subject prefixed with > [RFC][VOTE] > >> or similar. As noted you need to do it today or latest tomorrow. Feel > free > >> to let me know if you are too busy or something is not clear. > >> > >> I would recommend not to do any last time changes as in such case you > >> should probably give an extra time for dicusion which means it won't > make > >> the feature freeze and will have to wait for another year. In my > opinion it > >> is good as it is. The tabs can be later added as an extra flag. If the > flag > >> is set, we could just change default value for indent to 1 and use tabs > but > >> it would be still possible for users to set indent size if they wish. I > >> think that's something that makes most sense to me and doesn't impact > the > >> current RFC in any way. > >> > >> Regards > >> > >> Jakub > >> > > > > My thoughts might be firmly in the realms of "too little, too late" since > > the vote is open already, so by all means choose to ignore. > > I'll be on the same lines! > > What I would have prefered is instead of a the new parameter $indent > having a numerical value to have a string value. > > That would have allowed the following: > > json_encode($data, indent: " "); > > or > > json_encode($data, indent: "\t"); > > That would have made the tabs vs. spaces very easy and people can also > add whatever they want to set for one indentation. Think about setting > dots for making the spaces visible for some formatted output or whatever > else people might think of. > > The problem with this approach is that we either need to validate it (which is probably not a big deal but you still have just option or using spaces or tabs) or we allow invalid JSON to be produced from this function which I think it's not a good idea and should not be part of json_encode because, as its name suggests, that function is just for encoding JSON and not some random format. My guess is that it would be even less likely to pass and I would certainly vote against it. I think if this RFC fails, we could maybe allow number or validated string and also do that auto setting of flag if set as suggested. Regards Jakub --0000000000001ad58605e30b9fbe--