Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114896 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33578 invoked from network); 15 Jun 2021 21:30:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Jun 2021 21:30:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C1CED1804C0 for ; Tue, 15 Jun 2021 14:46:43 -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 autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f177.google.com (mail-vk1-f177.google.com [209.85.221.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 15 Jun 2021 14:46:40 -0700 (PDT) Received: by mail-vk1-f177.google.com with SMTP id 184so157567vkz.13 for ; Tue, 15 Jun 2021 14:46:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=H7LnxdFUUNzC0AHEcM0JntoZCzUZEqtiOdGBMZ4RBmw=; b=WfFufStTuibOGIuoEm29Mp2M89Z2S7vOhRXdUNMnhIa6PvkviZZdX4m4z9iIkxfXcu pXk4a0sO0lisK0GRuKHJvOUW1+jxxIJ7oZpQtBRLvBmbg5eTG7UsS2Bhf0rWleax/w/6 wQDu+1ggdytEAloI+Bj5rO2Bx8mYhoz5xVwW0iC1/H0FuTd8x6Fc44pPsp7b9s1I/+m+ GkRr+PWq/3OUlXd97AgNXUfbVsozmHkEoxC5xG9a1aD/ebQ7JkaANlNwZN95Z5u6JEJ5 PQzUd3WAAqb6vwDKl0+r94vjYpgJgPK3Y6gr5F6B+9YT1ftEoeKyXnH//QagZvhj6s7g LCKA== X-Gm-Message-State: AOAM5333pzefsIyRiqSZ6Pm482wtNd/SBZMdQYNd/ZIKQXuJ6NgEZIeB Oq7ZXHMz1pB1zgPw2oGsywhb/ulhKjmCqFaR1XM= X-Google-Smtp-Source: ABdhPJxQeYA+MWG3oRcOzCQjNg4SENew/IS30KQl2rBi0QNOn3BK3ibipBHVF8eEtounj/WGXhLwRU50V14OpjhEp/c= X-Received: by 2002:a1f:5043:: with SMTP id e64mr7085708vkb.21.1623793594220; Tue, 15 Jun 2021 14:46:34 -0700 (PDT) MIME-Version: 1.0 References: <8de4d96a-75d1-d732-020e-30bce0a5e03d@gmail.com> In-Reply-To: Date: Tue, 15 Jun 2021 22:46:23 +0100 Message-ID: To: Nikita Popov Cc: Timon de Groot , PHP internals Content-Type: multipart/alternative; boundary="0000000000005f430605c4d4e8e1" Subject: Re: [PHP-DEV] [RFC][Draft] Add json_encode indent parameter From: bukka@php.net (Jakub Zelenka) --0000000000005f430605c4d4e8e1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 7, 2021 at 11:53 AM Nikita Popov wrote: > On Thu, Jun 3, 2021 at 6:11 PM Timon de Groot > wrote: > > > Hi internals, > > > > I'd like to present my RFC for adding the indent parameter to the > > json_encode function: > > https://wiki.php.net/rfc/json_encode_indentation > > > > The `string|int $indent =3D 4` parameter adds the ability to specify th= e > > indentation for > > the JSON encoder. Amount of spaces can be specified by a number and a > > string can be > > specified to set a custom indentation like `\t` or whatever. > > > > As this is my first RFC (and contribution) for PHP, I'm all kind of new > > to the process, standards, etc. > > Please let me know if I could do something better. > > > > Looking forward to feedback/input on the RFC. > > > > As has been brought up in > https://github.com/php/php-src/pull/7093#issuecomment-855170601, the > string > version of the $indent parameter allows you to create invalid JSON, > something that json_encode() does not currently allow. I tend to agree th= at > it would make sense to validate that the indent only contains whitespace > characters, and not =F0=9F=9A=80. > > I agree with this, it should validated to be also consistent with UTF-8 validation. For example if it's not valid utf8, it returns false (unless ignoring or substitution is enabled). In any case it never returns invalid json atm. I don't think it's a good idea to break that assumption. Cheers Jakub --0000000000005f430605c4d4e8e1--