public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Isaev Ruslan <legale.legale@gmail.com>
Cc: Nicolas Escande <nico.escande@gmail.com>, linux-wireless@vger.kernel.org
Subject: Re: [PATCH v5] Add JSON output options to 'iw' for scan results
Date: Tue, 05 Mar 2024 14:29:55 +0100	[thread overview]
Message-ID: <172b85b1166c2f026df396ee4dabc3cbb2c300f9.camel@sipsolutions.net> (raw)
In-Reply-To: <CACDmYycV9qP2TUMMz5ij75A18NEaVpke6t70r7ELNgV=8+sCRw@mail.gmail.com>

On Tue, 2024-03-05 at 14:32 +0300, Isaev Ruslan wrote:
> 
> I think i could make a universal printf() like function with
> additional args for json representation.
> 
> Something like this:
> before:
> printf("\t * Manufacturer: %.*s\n", sublen, data + 4);
> 
> after:
> printf_json("\t * Manufacturer", "%.*s", sublen, data + 4);

I think you meant

printf_json("Manufacturer", "%.*s", sublen, data + 4);

but yeah, that seems better? Not sure I'd call it print_json() over just
print() or output() or so at that point.

> void printf_json(const char* key, const char* fmt, ...) {
>     char buf[1024];
>     va_list args;
>     va_start(args, format);
> 
>     if (iw_json) {
>         vsnprintf(buf, sizeof(buf), format, args);
>         print_string(PRINT_JSON, key, "%s", buf);
>     } else {
>         printf("\t * %s: ", key);

Guess we'd have to be careful about the indentation. Track the (JSON)
object nesting level and apply it that way?

johannes


  reply	other threads:[~2024-03-05 13:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5c5be485dcfceb44fc731e47758d6be3.legale.legale@gmail.com>
2024-03-05  9:41 ` [PATCH v5] Add JSON output options to 'iw' for scan results Johannes Berg
2024-03-05 10:17   ` Nicolas Escande
2024-03-05 10:31     ` Johannes Berg
2024-03-05 11:32       ` Isaev Ruslan
2024-03-05 13:29         ` Johannes Berg [this message]
2024-03-05 11:19     ` Isaev Ruslan
2024-03-05 15:55   ` Jeff Johnson
2024-03-05 16:35     ` Aditya Kumar Singh
2024-03-05 16:40       ` Johannes Berg
2024-03-05 17:47       ` Jeff Johnson
2024-03-04 20:01 Isaev Ruslan

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=172b85b1166c2f026df396ee4dabc3cbb2c300f9.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=legale.legale@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nico.escande@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox