KJSON_ARRAY_CLOSE(3)
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). slayKCGI_ENOMEMβ Internal memory allocation failure.KCGI_HUPβ The output connection has been terminated. For FastCGI connections, the current connection should be released withkhttp_free(3)and parse loop reentered.KCGI_FORMβ The connection is still expecting headers withkhttp_head(3). Indicates thatkhttp_body(3)did not return with success or was not invoked. For FastCGI connections, the current connection should be released withkhttp_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
- Copyright (c) 2020 Kristaps Dzonsons <kristaps@bsd.lv>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms