From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute 2/2] json_writer: fix builtin test code
Date: Fri, 10 Apr 2026 15:47:45 -0700 [thread overview]
Message-ID: <20260410224745.93416-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20260410224745.93416-1-stephen@networkplumber.org>
The code under #ifdef was not generating valid JSON
and it is missing test for control characters.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/json_writer.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/json_writer.c b/lib/json_writer.c
index 7202621e..d4a1c72b 100644
--- a/lib/json_writer.c
+++ b/lib/json_writer.c
@@ -369,7 +369,7 @@ int main(int argc, char **argv)
jsonw_null_field(wr, "my_null");
jsonw_name(wr, "special chars");
- jsonw_start_array(wr);
+ jsonw_start_object(wr);
jsonw_string_field(wr, "slash", "/");
jsonw_string_field(wr, "newline", "\n");
jsonw_string_field(wr, "tab", "\t");
@@ -377,7 +377,14 @@ int main(int argc, char **argv)
jsonw_string_field(wr, "quote", "\"");
jsonw_string_field(wr, "tick", "\'");
jsonw_string_field(wr, "backslash", "\\");
- jsonw_end_array(wr);
+ jsonw_end_object(wr);
+
+ jsonw_name(wr, "control chars");
+ jsonw_start_object(wr);
+ jsonw_string_field(wr, "bell", "\a");
+ jsonw_string_field(wr, "esc", "\033");
+ jsonw_string_field(wr, "del", "\177");
+ jsonw_end_object(wr);
jsonw_end_object(wr);
--
2.53.0
prev parent reply other threads:[~2026-04-10 22:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 22:47 [PATCH iproute 1/2] json_writer: support control character escaping Stephen Hemminger
2026-04-10 22:47 ` Stephen Hemminger [this message]
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=20260410224745.93416-2-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=netdev@vger.kernel.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