Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Stephen Hemminger
Sat, 24 Oct 2026 01:13
Re: [PATCH iproute2-next] json_writer: fix pretty printing of arrays
Author: Stephen Hemminger
Date: Sat, 24 Oct 2026 01:13
Date: Sat, 24 Oct 2026 01:13
17 lines
11204 bytes
11204 bytes
On Thu, 22 Oct 2026 21:10:07 +0000
Hadrien Patte <hadrien.patte@protonmail.com> wrote:
> Output now looks like:
>
> [
> {
> "ifindex": 1,
> "flags": [
> "UP",
> "LOWER_UP"
> ]
> },
Putting all the array elements on oneline is easier to read and more compact.
What does python do?
Re: [PATCH iproute2-next] json_writer: fix pretty printing of arrays
Author: Stephen Hemminger
Date: Sun, 25 Oct 2026 18:34
Date: Sun, 25 Oct 2026 18:34
47 lines
12731 bytes
12731 bytes
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
Re: [PATCH iproute2-next] json_writer: fix pretty printing of arrays
Author: 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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads