Article View: linux.kernel.netdev
Article #7240Re: [PATCH iproute2-next] json_writer: fix pretty printing of arrays
From: David Ahern
Date: Sun, 25 Oct 2026 19:42
Date: Sun, 25 Oct 2026 19:42
51 lines
9550 bytes
9550 bytes
On 10/25/26 12:34 PM, Stephen Hemminger wrote:
> On Sat, 24 Oct 2026 18:50:46 +0000
> Hadrien Patte <hadrien.patte@protonmail.com> wrote:
>
>> On Fri, 23 Oct 2026 18:13:02 -0700
>> Stephen Hemminger <stephen@networkplumber.org> wrote:
>>
>>> Putting all the array elements on oneline is easier to read and more compact.
>>> What does python do?
>>
>> My current patch actually contains two separate changes:
>>
>> 1. A fix for arrays of objects. Scalar arrays render fine on a single
>> line, but when the elements are objects, which contain newlines, the
>> brackets and separators end up glued to them and the indentation
>> levels of opening and closing brackets are off:
>>
>> # ip -j -p addr show dev lo
>> [ {
>> "ifindex": 1,
>> "ifname": "lo",
>> "flags": [ "LOOPBACK","UP","LOWER_UP" ],
>> ...
>> "addr_info": [ {
>> "family": "inet",
>> "local": "127.0.0.1",
>> ...
>> },{
>> "family": "inet6",
>> "local": "::1",
>> ...
>> } ]
>> } ]
>>
>> 2. Putting each element of scalar arrays on its own line. This is a
>> style change rather than a fix, though it is consistent with common
>> JSON pretty-printers such as jq or python's json.dumps.
>>
>> I'm happy to send a v2 that only keeps the first part, leaving scalar
>> arrays in their current single-line form if you prefer.
>>
>> Thanks,
>> Hadrien
>>
>
> Looks ok, as is. more of an observation by me.
> I don't in general look at json pretty print
Meaning you are good with both changes? If so, Hadrien the 2 separate
changes should be 2 separate patches if possible.
Technical Details
Message-ID:
<65dc14b8-8e9f-4a70-8698-2bf12cbce5f0@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351604-linux-kernel-netdev=dewy.ruReferences:
<20261022211002.31098-1-hadrien.patte@protonmail.com> <20261023181302.2a06fe99@stephen-xps.local> <20261024183341.34161-1-hadrien.patte@protonmail.com> <20261025113418.2f5acab4@phoenix.local>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351604-linux-kernel-netdev=dewy.ru From: dsahern@kernel.org (David Ahern) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH iproute2-next] json_writer: fix pretty printing of arrays Date: Sun, 25 Oct 2026 13:42:41 -0600 Organization: Usenet Network Message-ID: <65dc14b8-8e9f-4a70-8698-2bf12cbce5f0@kernel.org> References: <20261022211002.31098-1-hadrien.patte@protonmail.com> <20261023181302.2a06fe99@stephen-xps.local> <20261024183341.34161-1-hadrien.patte@protonmail.com> <20261025113418.2f5acab4@phoenix.local> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1114051"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:nXf3Ba1NgkYzQZOrFRjjh9vvcMI= sha256:XPz8TGwMSB3w9teLpTq98uEkMbgjT+QvzZfwqCjMF9Q= sha1:f0VeOjXxPMkO1DF1iXx3FOhjAfo= sha256:hr9Zfh89l8brbfJM35Ktf73SpTHBGZ3bJ/caVVSwkno= Content-Language: en-US List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id C436D125B4B; Sun, 25 Oct 2026 22:42:59 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.739 X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2lQjsYzEUWnK; Sun, 25 Oct 2026 22:42:56 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-351604-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 95819125B49; Sun, 25 Oct 2026 22:42:48 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 490392B58C; Sun, 25 Oct 2026 19:42:44 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792957363; b=YbTTgWyftOjLSOOCV7WR8krTdb9Ls8Tufa1lDrbbLsp1CrTfSpAg9uHMcasz6Hot/fwN EhOIqEg/2EgO3a+dnFoNEBtUOyqep8oJ5DirX2F5Px+FjSUDXx/PsvFKLU1qghkWytPvr aYZxqqlw8uFCuW6DDihzV4GWn4TpaH9BqdPVQufjtbp95tEdP9fPX5mRrNCRs+sGVaO59 umBvckn39GS5bZOCfhn8QONq0yDrrQuiANN9s4JRh78I4N5p8oWf33I4Ng+EOc+t41ESM WpNsg916fvJXnCJ5UoEKECRx91DhlDy9jYCfk2wChbfqMKuwcEovNtDPLMAaGv8LzhQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792957363; h=X-Original-To:Received:Received:DKIM-Signature:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:Content-Language:To:Cc:References:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=gJdqFv7x5YJU260/H/Wz300qdhKDuJnZTzjsirnU2yY=; b=1n1vanI7zO1EGVsMCo9Ai4f+DuF7wCY1kUbyjQqaAm39Zg7H39j1WcP8DtdnOKS46BEj mFh1fl2ciACMNDrMMcbrHp7nr1xcv4CquGGmCZriovq+DZQAJqEsQzu0N+m4Xsi/zXNW3 rM1jfTqln2BUUfQ764JJu4YVjuFpED0wrPwcSD6FI4+HaXMKJ5T9nZrEHo1sT5NEwobam CUMepJlLTLZUXrb7BNrMIIKPJTl8rU0KHDR1nm6GTEhlBCydRS/lIPPvg9dOKOTrcD5Kq FvpN1ubbVJr/FSFD5MHKIXc4VhtMb9N0mZ4D5NZt5kZxi1eSw4wc6MbagIEoYtpnnIQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mkzUrowP; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99E2F606A321; Sun, 25 Oct 2026 19:42:43 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mkzUrowP X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792957362; b=h070qGxDIgy+YHuu8QITxaYkhBayxvyBDDIz6wmv0w9LRG5Igdjak2uSBCyZoTDlLbN1 A/URn0GqGMpX2qdtBfRMiDzO3fvO/0D33JzKtIQpnlM1+c3NJVjhBw7aVv0gxgFobVrfw TKfhFebYqlx8GkkLWIRmvHapqKaZYbbTclG0iNnbYsJUI3BEN6BG8XCNHgWuZbHRfaEmI RhNOjC3B8RRUe0OwLhd3RdDPMfAY7HJPP1lhFeQub8iDDjXR2QL2QvaLuceXha2lLxqre zxx91e2isvl3Rq8Pguehs4xA0nT8MwqrBrTtFrOyWx/BF5N/FkLOIT0shNNr3bHtdqg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792957362; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:Content-Language:To:Cc:References:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=gJdqFv7x5YJU260/H/Wz300qdhKDuJnZTzjsirnU2yY=; b=V6XKs8aJLgq5VARVwUhi9Xv0wiwjPIcLLCmCy+pLkqGuIsntqSJZLdF0rgnFWuqmbRLK kJg7cYCLEz7rdM/v1W85WJ8h4P7Mr2e65xfLArIkg0rZfwx/VyX0fQfLXMu53EsLQEZYd hQ0WOV2DwXnkeaBqEI/qqvHYvRq6fp3hRiyA8xuf5YPUrsLC2T00HEn1mZgmw/ZB/djhK MFiOskM7CNKVsQp5tlsSIby0tjEX9fUMwHRfQC79wQ7ozjIZvRkalGwNJEbB8q60BV3pi /6t186/7hgsS6MJ202i5G6HVO+LMLlGG12RLRjn7bJeszbs56JydHsCuHJndZ6CUEWw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mkzUrowP; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 811D0606A31D for <netdev@vger.kernel.org>; Sun, 25 Oct 2026 19:42:42 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB3631F01825; Sun, 25 Oct 2026 19:42:41 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792957362; bh=gJdqFv7x5YJU260/H/Wz300qdhKDuJnZTzjsirnU2yY=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=mkzUrowPC1HsKietLuoqNl3uxq8pxMCrlZiVNUJGZtmHLPZqZBvzpIssHDO/UNhlC J/AqYyRZNjpsd3xr2HD2kxyiCdyS5oG46WJVWG0SHzce6/R99SDDeHhhm+9vDn+pwM CFBelN6NE3jSAfC5l1OheXstccNiIwZOM6JH8oe/YWyITVgBVKiKILln6PAUyuNbMA 24klitjB+8IKIIiMRwQzNkdC6g7onl7IhUctYAB7Frt3DyJGqp9sZa7OiHdtJYPeqO 9jqDkWwYG/wP8dH9svPre60c5/uOcgHmdACcyg4j4xrz8MCWwquGtPeVkMf289rVv0 RV5ADSbkKm99g== X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-Cc: netdev@vger.kernel.org X-In-Reply-To: <20261025113418.2f5acab4@phoenix.local>