All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Cc: Roopa Prabhu <roopa@cumulusnetworks.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Nikolay Aleksandrov <nikolay@cumulusnetworks.com>,
	Julien Fortin <julien@cumulusnetworks.com>
Subject: Re: [PATCH iproute2 net-next 3/5] bridge: add json support for bridge fdb show
Date: Fri, 17 Jun 2016 12:04:27 -0700	[thread overview]
Message-ID: <20160617120427.1e8ba9a3@xeon-e3> (raw)
In-Reply-To: <CACcJQnTqkOXpuhRGM1tpJH-sEdMxS3Voux46tphi+pdydTU_4w@mail.gmail.com>

On Fri, 17 Jun 2016 11:04:54 -0700
Anuradha Karuppiah <anuradhak@cumulusnetworks.com> wrote:

> On Tue, May 31, 2016 at 12:22 PM, Anuradha Karuppiah
> <anuradhak@cumulusnetworks.com> wrote:
> > On Tue, May 31, 2016 at 11:59 AM, Stephen Hemminger
> > <stephen@networkplumber.org> wrote:
> >> On Fri, 27 May 2016 21:37:14 -0700
> >> Roopa Prabhu <roopa@cumulusnetworks.com> wrote:
> >>
> >>> Sample output:
> >>> $bridge -j fdb show
> >>> [{
> >>>         "mac": "44:38:39:00:69:88",
> >>>         "dev": "swp2s0",
> >>>         "vlan": 2,
> >>>         "master": "br0",
> >>>         "state": "permanent"
> >>>     },{
> >>>         "mac": "00:02:00:00:00:01",
> >>>         "dev": "swp2s0",
> >>>         "vlan": 2,
> >>>         "master": "br0"
> >>>     },{
> >>>         "mac": "00:02:00:00:00:02",
> >>>         "dev": "swp2s1",
> >>>         "vlan": 2,
> >>>         "master": "br0"
> >>>     },{
> >>>         "mac": "44:38:39:00:69:89",
> >>>         "dev": "swp2s1",
> >>>         "master": "br0",
> >>>         "state": "permanent"
> >>>     },{
> >>>         "mac": "44:38:39:00:69:89",
> >>>         "dev": "swp2s1",
> >>>         "vlan": 2,
> >>>         "master": "br0",
> >>>         "state": "permanent"
> >>>     },{
> >>>         "mac": "44:38:39:00:69:88",
> >>>         "dev": "br0",
> >>>         "master": "br0",
> >>>         "state": "permanent"
> >>>     }
> >>>     ]
> >>
> >> In most JSON I have seen, the output would be:
> >>
> >> {
> >>   "fdb" : [
> >>      {
> >>          "mac": "44:38:39:00:69:88",
> >>          "dev": "swp2s0",
> >>          "vlan": 2,
> >>          "master": "br0",
> >>          "state": "permanent"
> >>      },
> >> ...
> >>    ]
> >> }
> >>
> >> I.e never a bare array.
> >>
> > Yes Stephen, Adding an extra level would be one way to force the
> > format to json-object. And that would definitely be the way to do it
> > if we ever added a top level json dump - something like - "bridge -j
> > show".
> >
> > But in the case of "bridge -j fdb show" that level is redundant. To be
> > consistent we would have to add that extra level to all json dumps
> > (even if they were already objects; such as the "bridge -j vlan
> > show").The google json style guide recommends against adding hierarchy
> > unless needed. And it is not that uncommon in java to have a
> > json-array of objects for e.g. http://json-schema.org/example1.html
> > talks about a schema that is an "array of products".
> >
> > What do you recommend?
> 
> Hi Stephen,
> We did a bit more digging around and found that other folks use json
> output with top level array as well. Here’s a docker networks json
> output sample -
> 
> vagrant@host-21 ~ $ docker network inspect red
> [
>     {
>         "Name": "red",
>         "Id": "d2fff9bafd7564c4012aa49f322fcd8f5743cc5ceb465dc218af5ba22c920981",
>         "Scope": "global",
>         "Driver": "overlay",
>         "EnableIPv6": false,
>         "IPAM": {
>             "Driver": "default",
>             "Options": {},
>             "Config": [
>                 {
>                     "Subnet": "10.252.20.0/24"
>                 }
>             ]
>         },
>         "Internal": false,
>         "Containers": {
>             "c92084c1ebfb4f0a601537298c273078862207e3b564787ddd6ef564efbaca47":
> {
>                 "Name": "ctr21",
>                 "EndpointID":
> "e7468a70f13f1ea7b15445ab555374892ac41f71ea9023af1d9ede668bfd8742",
>                 "MacAddress": "02:42:0a:fc:14:03",
>                 "IPv4Address": "10.252.20.3/24",
>                 "IPv6Address": ""
>             },
>             "ep-9bfc004b4046512f0f0104fe022d3686f5237ae08475741f8d520552cbb63d45":
> {
>                 "Name": "ctr22",
>                 "EndpointID":
> "9bfc004b4046512f0f0104fe022d3686f5237ae08475741f8d520552cbb63d45",
>                 "MacAddress": "02:42:0a:fc:14:02",
>                 "IPv4Address": "10.252.20.2/24",
>                 "IPv6Address": ""
>             }
>         },
>         "Options": {},
>         "Labels": {}
>     }
> ]
> 
> Adding an additional namespace to all the json outputs (just to avoid
> a top-level json-array for some) seems redundant. If a namespace is
> needed for other reasons we can definitely add it. So we think it
> would be better to just go with the top-level json-array for a
> list/set-of-objects outputs.

Ok, resubmit. I never claimed to be a JSON expert :=)

  reply	other threads:[~2016-06-17 19:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-28  4:37 [PATCH iproute2 net-next 3/5] bridge: add json support for bridge fdb show Roopa Prabhu
2016-05-31 18:59 ` Stephen Hemminger
2016-05-31 19:22   ` Anuradha Karuppiah
2016-06-17 18:04     ` Anuradha Karuppiah
2016-06-17 19:04       ` Stephen Hemminger [this message]
2016-06-17 19:07         ` Anuradha Karuppiah

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=20160617120427.1e8ba9a3@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=anuradhak@cumulusnetworks.com \
    --cc=julien@cumulusnetworks.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=roopa@cumulusnetworks.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.