3
.\" Copyright (c) 2020 Kristaps Dzonsons <kristaps@bsd.lv>
5
.\" Permission to use, copy, modify, and distribute this software for any
6
.\" purpose with or without fee is hereby granted, provided that the above
7
.\" copyright notice and this permission notice appear in all copies.
9
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
.Nd put string content for kcgijson
35
.Fa "struct kjsonreq *req"
40
.Fa "struct kjsonreq *req"
46
.Fa "struct kjsonreq *req"
65
form is for array scopes,
71
All values are JSON escaped so that content cannot prematurely end its
80
is equivalent to calling
85
indicating the error state.
88
Success (not an error).
90
Internal memory allocation failure.
92
The output connection has been terminated.
93
For FastCGI connections, the current connection should be released with
95
and parse loop reentered.
97
The connection is still expecting headers with
101
did not return with success or was not invoked.
102
For FastCGI connections, the current connection should be released with
104
and parse loop reentered.
106
Internal system error writing to the output stream.
108
The incorrect form was used for the current scope, for example, an
109
array-type write within an object.
112
The following outputs a simple JSON document.
118
For brevity, it does not do any error checking.
119
.Bd -literal -offset indent
120
khttp_head(r, kresps[KRESP_STATUS],
121
"%s", khttps[KHTTP_200]);
122
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
123
"%s", kmimetypes[KMIME_APP_JSON]);
127
kjson_putstringp(&req, "bar", "shbar");
128
kjson_arrayp_open(&req, "baz");
129
kjson_putstring(&req, "xyzzy"));
136
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .