git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, ps@pks.im, karthik.188@gmail.com,
	Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Subject: [GSoC PATCH v2 2/2] json-writer: describe the usage of jw_* functions
Date: Sun, 11 May 2025 23:09:35 -0300	[thread overview]
Message-ID: <20250512020935.73140-3-lucasseikioshiro@gmail.com> (raw)
In-Reply-To: <20250512020935.73140-1-lucasseikioshiro@gmail.com>

Provide an overview of the set of functions used for manipulating
json_writers by describing what functions should be used for each
JSON-related task.

Helped-by: Junio C Hamano <gitster@pobox.com>
Mentored-by Patrick Steinhardt <ps@pks.im>
Mentored-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 json-writer.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/json-writer.h b/json-writer.h
index aa513e86cb..8b7470af67 100644
--- a/json-writer.h
+++ b/json-writer.h
@@ -28,6 +28,34 @@
  * object/array) -or- by building them inline in one pass.  This is a
  * personal style and/or data shape choice.
  *
+ * USAGE:
+ * ======
+ *
+ * - Initialize the json_writer with jw_init.
+ *
+ * - Open an object as the main data structure with jw_object_begin.
+ *   Append a key-value pair to it using the jw_object_<type> functions.
+ *   Conclude with jw_end.
+ *
+ * - Alternatively, open an array as the main data structure with
+ *   jw_array_begin. Append a value to it using the jw_array_<type>
+ *   functions. Conclude with jw_end.
+ *
+ * - Append a new, unterminated array or object to the current
+ *   object using the jw_object_inline_begin_{array, object} functions.
+ *   Similarly, append a new, unterminated array or object to
+ *   the current array using the jw_array_inline_begin_{array, object}
+ *   functions.
+ *
+ * - Append other json_writer as a value to the current array or object
+ *   using the jw_{array, object}_sub_jw functions.
+ *
+ * - Extend the current array with an null-terminated array of strings
+ *   by using jw_array_argv or with a fixed number of elements of a
+ *   array of string by using jw_array_argc_argv.
+ *
+ * - Relase the json_writer after using it by calling jw_release.
+ *
  * See t/helper/test-json-writer.c for various usage examples.
  *
  * LIMITATIONS:
-- 
2.39.5 (Apple Git-154)


  parent reply	other threads:[~2025-05-12  2:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-12  2:09 [GSoC PATCH v2 0/2] json-writer: describe the jw_* functions Lucas Seiki Oshiro
2025-05-12  2:09 ` [GSoC PATCH v2 1/2] json-writer: add docstrings to " Lucas Seiki Oshiro
2025-05-12  8:50   ` Patrick Steinhardt
2025-05-13 22:05     ` Lucas Seiki Oshiro
2025-05-14  2:41       ` Patrick Steinhardt
2025-05-12  9:36   ` Karthik Nayak
2025-05-12  2:09 ` Lucas Seiki Oshiro [this message]
2025-05-12  8:50   ` [GSoC PATCH v2 2/2] json-writer: describe the usage of " Patrick Steinhardt
2025-05-12  9:41   ` Karthik Nayak
2025-05-13 22:22     ` Lucas Seiki Oshiro
2025-05-14  2:40       ` Patrick Steinhardt
2025-05-12  8:49 ` [GSoC PATCH v2 0/2] json-writer: describe the " Karthik Nayak

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=20250512020935.73140-3-lucasseikioshiro@gmail.com \
    --to=lucasseikioshiro@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karthik.188@gmail.com \
    --cc=ps@pks.im \
    /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;
as well as URLs for NNTP newsgroup(s).