JSON input / output for CLI utilities

Andrew Walker awalker at ixsystems.com
Fri May 28 15:10:02 UTC 2021


On Thu, May 27, 2021 at 8:03 PM Douglas Bagnall <
douglas.bagnall at catalyst.net.nz> wrote:

> On 28/05/21 9:42 am, Andrew Walker via samba-technical wrote:
> > I know we've added JSON output to a few of the CLI utils. Over the past
> > year or so I've added this to various utils in FreeNAS (using
> libjansson).
> > Is there an overall strategy for this? I'd be happy to upstream what I
> have.
>
> Yes, please upstream.
>
> I think the strategy is to look around and aim for consistency between
> tools, but don't let the lack of clear conventions stop you.
>
> jansson is the right thing for C; the standard python library is right
> for python.
>
> > Also is there an effort to add support for JSON input to them?
>
> No effort, but I think we would want to where it makes sense.
>
> Douglas
>

Should we have version strings for all the JSON output generated by
utilities?

 root@:/usr/ports/net/samba # net --json groupmap list -v | jq
{
  "version": {
    "major": 1,
    "minor": 0
  },
  "groupmap": [
    {
      "nt_name": "Guests",
      "sid": "S-1-5-32-546",
      "gid": 90000016,
      "group_type_int": 4,
      "group": "BUILTIN\\guests",
      "group_type_str": "Local Group"
    },
    {
      "nt_name": "Administrators",
      "sid": "S-1-5-32-544",
      "gid": 90000014,
      "group_type_int": 4,
      "group": "BUILTIN\\administrators",
      "group_type_str": "Local Group"
    },
    {
      "nt_name": "Users",
      "sid": "S-1-5-32-545",
      "gid": 90000015,
      "group_type_int": 4,
      "group": "BUILTIN\\users",
      "group_type_str": "Local Group"
    }
  ]
}


More information about the samba-technical mailing list