KJSON_OBJ_OPEN(3)
π KJSON_OBJ_OPEN(3) π
okay so this is the KJSON_OBJ_OPEN(3) page from the Library Functions Manual, and bestie, it's lowkey a whole moment. it's about opening object scopes for kcgijson β come get your JSON nesting situation going β¨
πΈ NAME πΈ
kjson_obj_open, kjson_objp_open β open object scope for kcgijson (yes bestie, that's the whole name vibe π
)
π¦ LIBRARY π¦
library βlibkcgijsonβ β that's where this little icon lives π«Ά
β¨ SYNOPSIS β¨
drop these includes first, then pick your function:
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
#include <kcgijson.h>
enum kcgi_err
kjson_obj_open(struct kjsonreq *req);
enum kcgi_err
kjson_objp_open(struct kjsonreq *req, const char *name);
π DESCRIPTION π
Open an object scope in a context req initialised with khtml_open(3). Scopes are closed with kjson_obj_close(3) or kjson_close(3). Object scopes may be filled in with further named pairs as with kjson_putstringp(3).
The kjson_obj_open() form is for array scopes, while kjson_objp_open() is for objects.
Passing a NULL value to name for kjson_objp_open() is equivalent to calling kjson_obj_open().
π RETURN VALUES π
Returns an enum kcgi_err indicating the error state. vibe check time:
KCGI_OKβ success, and no cap it's not an error πKCGI_ENOMEMβ internal memory allocation failure, including reaching the maximum number of possible JSON scopes π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 incorrect form was used for the current scope, for example, an array-type write within an object. it's giving wrong-scope energy, fr fr π©
π₯ 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.
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_putstringp(&req, "bar", "shbar");
kjson_arrayp_open(&req, "baz");
kjson_putstring(&req, "xyzzy"));
kjson_close(&req);
π SEE ALSO π
kcgijson(3) β go peek at the parent page, iykyk π
π AUTHORS π
Written by Kristaps Dzonsons <kristaps@bsd.lv>.
okay that's the whole page, bestie π«Ά β source Debian, footer date stamp $Mdocdate$, and this is KJSON_OBJ_OPEN(3) signing off. periodt π
π¦ 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