Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118164 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76614 invoked from network); 3 Jul 2022 20:09:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jul 2022 20:09:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E9771180211 for ; Sun, 3 Jul 2022 15:01:53 -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=0.5 required=5.0 tests=BAYES_40, 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-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 ; Sun, 3 Jul 2022 15:01:50 -0700 (PDT) Received: by mail-ej1-f43.google.com with SMTP id fw3so13626907ejc.10 for ; Sun, 03 Jul 2022 15:01:50 -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=N08LQSjzi0I8XTJC+5ezfEmjKIJjsAIBA1KGzOt8xIU=; b=6D72MvHzK97i6Wwt8VawKEosIhph5H1u7FGc/U9bE+L79e+2igtzz25Kc28CDj7Ycu LLDGXVpYhoKuWW3JU5Gxulqyw/9BuMa51MG5Z/j82bCqzdNvc39SNTyVPNeJzoIUw1AN DAwOqcVrKm6nL6rDh5kMYbeQcSaSHy6hzNnP8rAmzPtRjXLSkRmz3rDZVSKARZZbvoOK ABL+2U5Kbyw5ncQnKv3h/bjE20Qxgp6k3R8SMFmWac5etCLkOZEY1BNyKFEjpn7m+Two Xs4dgDhDCUadlCxlhRoLXvL30ANveVb6ZHtR592lXixOudltrH1H7dBb8aj1i29BLAin KgvQ== X-Gm-Message-State: AJIora+iQFhuc27Moupk5Tryaw6WrSZtar9q0BXerdtItASluWWfEn/w R4RYHBG6l802G/slO4w0KSdnRTThCKl1OBYMI3N1oao0 X-Google-Smtp-Source: AGRyM1vQAD42Zo//FaCyjy8ZItFuh50lxC1AhqOWbogMwGo7U3TsLp/RwTeXLKpoEre97cXe7xIW6jOMOJQvMFLaHRc= X-Received: by 2002:a17:907:7d88:b0:726:2adb:2073 with SMTP id oz8-20020a1709077d8800b007262adb2073mr26212287ejc.466.1656885709185; Sun, 03 Jul 2022 15:01:49 -0700 (PDT) MIME-Version: 1.0 References: <7d72b5c1-d19b-8734-57e0-f02c402b09c2@gmail.com> In-Reply-To: <7d72b5c1-d19b-8734-57e0-f02c402b09c2@gmail.com> Date: Sun, 3 Jul 2022 23:01:38 +0100 Message-ID: To: Timon de Groot Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000021254105e2edc4f8" Subject: Re: [PHP-DEV] [RFC] Add json_encode indent parameter From: bukka@php.net (Jakub Zelenka) --00000000000021254105e2edc4f8 Content-Type: text/plain; charset="UTF-8" Hi, On Fri, May 13, 2022 at 2:33 PM Timon de Groot wrote: > Hi internals, > > Almost a year ago I first proposed my RFC draft to introduce a new > json_encode parameter 'indent'. I have received a lot of feedback on the > change, very insightful. The feedback can be boiled down to: > - Accepting user input characters means you could create invalid JSON. > Do we want that? Should it be complying with the spec[1]? > - Preference for pure types, so int OR string, not both. > > So I think I made the change more complex than it should have been and > considered the three options: > 1) Accept indent as an int, which will result in N spaces of indent > per indentation level. > 2) Accept indent as a string, which will result in string N per > indentation level. > 3) Accept indent as an int and indent_char as string, which will > result in N * indent_char per indentation level. > > Option 1 seems very simple and feasible while not being confusing. > Option 2 seems feasible, but somewhat more complex, because user input > should be validated. > Option 3 seems very flexible, but in my opinion very confusing at the > same time, while I'm not sure there's even a use case for this level of > flexibility. > > I have updated the pull request[2] and RFC[3] to be based on option 1, > as I think this offers clear functionality and I feel like I can't > really go wrong with the indent parameter as an int. > > Please let me know what your thoughts are and what needs to be done to > get this RFC going forward! > > I think we can put this RFC to the vote. If the author is to busy I would like to start voting later this week. It would be a pity not to make it to feature freeze as it is quite straight forward and the implementation seems good as well so I guess we don't need to wait extra year. :) Cheers Jakub --00000000000021254105e2edc4f8--