Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118195 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 3191 invoked from network); 5 Jul 2022 05:52:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jul 2022 05:52:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B218418054D for ; Tue, 5 Jul 2022 00:45:12 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (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 00:45:12 -0700 (PDT) Received: by mail-yb1-f176.google.com with SMTP id l144so7909672ybl.5 for ; Tue, 05 Jul 2022 00:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DlhLNjY/0+sm6U/uPL8OjIeO0pe6YizTUGMYiLEEqHs=; b=MSrk2JyLAWwsEjoi3GhQTvuMRZ0wasYXr/SsIY8NAvj/JSdQaQL09deI44jDIQLUPJ l9DSwCcBGXxCBAP87oTbMwm6l/Rw3oBg5v1DwlMkHoITIy354Sy/plf9VZX3hnAIrUd2 55grN/byEklgHFvV9ILycplS3U/A6x/JfpazpJOsDERxYblHBLuPFV5IbMPIzX1w+I58 Qatn16bv+lJpNq8oQuaHIsb+TaBhlZovcgHrj4KXwYPHT9lc5tR6qeyjfCzjVwmY4Jv6 /oeKbFmgbx72x/wm3oGrDIZGBmSAxTCxhp4aBT4McPMrSdRV6MKeM0oL8mY/mzfSUDVs 3WxA== 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=DlhLNjY/0+sm6U/uPL8OjIeO0pe6YizTUGMYiLEEqHs=; b=1TDpWtbUTQF1JASskXodgZ1NOBXBQTSDIXBQfNxxNX649l7eDRFHp1eTYLdEl5VmR2 h+u32rUzlM/xSLqUsHMENsqN4TFLxfqZ2r0cbV8TQE1eMxSIqCkYgXbS0wLB8rNW74vc CDJ7jTBACa+nI2cRBw3nRHqb2hVPAZM4BmpTABLQ5C9wQ6sJe5vg9WboBcGMQVcbR2dn zW/kaMdu5lvMaFdzeQsT/19mnzr24/PlNXYw2Bmwvnrt4kgz22IVRUNg8CeuZr0DPqXt mH/lj5nu2uPklIyq9hwDWWIiQYYp+gsbrHT0KXWU8oXur0oX7xFrlvB7xTzugjYkUZJ0 srFQ== X-Gm-Message-State: AJIora9dajhU1Wo6EsAM7wRaJDrG20Y94BlCFTosy93iUhB1aJR2QGrn 2HmuXzXY2iiB2FrfvoBlARNwPLBqG0KmRpo6tVibgHKrqQrUGQ== X-Google-Smtp-Source: AGRyM1tMcvUxOIKexa2Z6UDH/uZz40ajFjQ2MLKtM97wXhU3iVeGhDTl+IfT3Oq/O3FKc7sKVJYpj/hNt1G2Pp+BoSU= X-Received: by 2002:a25:3383:0:b0:66b:6205:1583 with SMTP id z125-20020a253383000000b0066b62051583mr34885238ybz.387.1657007111744; Tue, 05 Jul 2022 00:45:11 -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: Tue, 5 Jul 2022 09:44:59 +0200 Message-ID: To: Timon de Groot Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000004931bc05e30a0823" Subject: Re: [PHP-DEV] [RFC] Add json_encode indent parameter From: ocramius@gmail.com (Marco Pivetta) --0000000000004931bc05e30a0823 Content-Type: text/plain; charset="UTF-8" Hey Timon, On Fri, 13 May 2022 at 15:33, 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! > > -- > > Kind regards, > Timon > > [1] https://datatracker.ietf.org/doc/html/rfc4627 > [2] https://github.com/php/php-src/pull/7093 > [3] https://wiki.php.net/rfc/json_encode_indentation > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php I went with "NO" here for various reasons: 1. usage of `JSON_PRETTY_PRINT` is already rare enough to make the relevance of this parameter almost null 2. complicates an API signature for a very tiny detail 3. if the problem is linting/preferences, have your favorite linter process the file in the way you deem most appropriate Doesn't need to live in php-src. Greets, Marco Pivetta https://twitter.com/Ocramius https://ocramius.github.io/ --0000000000004931bc05e30a0823--