Netdev List
 help / color / mirror / Atom feed
From: Hadrien Patte <hadrien.patte@protonmail.com>
To: stephen@networkplumber.org
Cc: dsahern@kernel.org, hadrien.patte@protonmail.com, netdev@vger.kernel.org
Subject: Re: [PATCH iproute2-next] json_writer: fix pretty printing of arrays
Date: Sat, 24 Oct 2026 18:50:46 +0000	[thread overview]
Message-ID: <20261024183341.34161-1-hadrien.patte@protonmail.com> (raw)
In-Reply-To: <20261023181302.2a06fe99@stephen-xps.local>

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


  reply	other threads:[~2026-10-24 18:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 21:10 [PATCH iproute2-next] json_writer: fix pretty printing of arrays Hadrien Patte
2026-10-24  1:13 ` Stephen Hemminger
2026-10-24 18:50   ` Hadrien Patte [this message]
2026-10-25 18:34     ` Stephen Hemminger
2026-10-25 19:42       ` David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261024183341.34161-1-hadrien.patte@protonmail.com \
    --to=hadrien.patte@protonmail.com \
    --cc=dsahern@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox