KJSON_ARRAY_CLOSE(3)

πŸ“¦ version 1.0.1, in alpine 3.24

bestie, this is kjson_array_close(3) from the Library Functions Manual β€” the header line says hi, but we’re folding it in up here instead of copying it, periodt πŸ’…

🌸 NAME 🌸

kjson_array_close β€” open array scope for kcgijson 🌈

πŸŽ€ LIBRARY πŸŽ€

library β€œlibkcgijson” β€” that’s the whole squad, no cap.

✨ SYNOPSIS ✨

okay so first you gotta pull in all these headers, bestie, no skipping:

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
#include <kcgijson.h>

and then the function itself is giving:

enum kcgi_err
kjson_array_close(struct kjsonreq *req);

πŸ¦‹ DESCRIPTION πŸ¦‹

Closes an array scope created with kjson_array_open(3) or kjson_arrayp_open(3) in a context req initialised with khtml_open(3).

It is an error to close a non-array scope β€” like, do not do that, bestie 😭. That’s a vibe mismatch and the function will clock it.

πŸ’… RETURN VALUES πŸ’…

Returns an enum kcgi_err indicating the error state. Here’s the whole roster, no cap:

  • KCGI_OK β€” Success (not an error). slay
  • KCGI_ENOMEM β€” Internal memory allocation failure.
  • KCGI_HUP β€” The output connection has been terminated. For FastCGI connections, the current connection should be released with khttp_free(3) and parse loop reentered.
  • KCGI_FORM β€” The connection is still expecting headers with khttp_head(3). Indicates that khttp_body(3) did not return with success or was not invoked. For FastCGI connections, the current connection should be released with khttp_free(3) and parse loop reentered.
  • KCGI_SYSTEM β€” Internal system error writing to the output stream.
  • KCGI_WRITER β€” The current scope is not an array. big yikes if you hit this one πŸ’€

🌟 EXAMPLES 🌟

The following outputs a simple JSON document. It assumes r is a struct kreq pointer. For brevity, it does not do any error checking β€” don’t come for me πŸ™ˆ.

             khttp_head(r, kresps[KRESP_STATUS],
               "%s", khttps[KHTTP_200]);
             khttp_head(r, kresps[KRESP_CONTENT_TYPE],
               "%s", kmimetypes[KMIME_APP_JSON]);
             khttp_body(r);
             kjson_open(&req, r);
             kjson_obj_open(&req);
             kjson_objp_open(&req, "foo");
             kjson_arrayp_open(&req, "data");
             kjson_putstring(&req, "1");
             kjson_putstring(&req, "2");
             kjson_array_close(&req); /* data */
             kjson_putstringp(&req, "xyzzy");
             kjson_close(&req);

πŸ‘‘ SEE ALSO πŸ‘‘

kcgijson(3) β€” go check the whole family, iykyk πŸ’œ

🌈 AUTHORS 🌈

Written by Kristaps Dzonsons <kristaps@bsd.lv>.


okay that’s the whole page β€” brought to you by Debian, stamped $Mdocdate$, with the footer energy of KJSON_ARRAY_CLOSE(3) πŸ’–βœ¨

πŸ“¦ where this page comes from
  • alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms