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.
18
.Dt KJSON_STRING_WRITE 3
22
.Nd put content data for kcgijson
42
into a string scope opened with
43
.Xr kjson_string_open 3
45
.Xr kjson_stringp_open 3
52
and passed as an opaque pointer.
59
is zero, do nothing and return
62
All characters are JSON escaped so that content cannot prematurely end
67
indicating the error state.
70
Success (not an error).
72
Internal memory allocation failure.
74
The output connection has been terminated.
75
For FastCGI connections, the current connection should be released with
77
and parse loop reentered.
79
The connection is still expecting headers with
83
did not return with success or was not invoked.
84
For FastCGI connections, the current connection should be released with
86
and parse loop reentered.
88
Internal system error writing to the output stream.
90
The incorrect form was used for the current scope, for example, an
91
array-type write within an object.
94
The following outputs a simple JSON document.
100
For brevity, it does not do any error checking.
101
.Bd -literal -offset indent
102
khttp_head(r, kresps[KRESP_STATUS],
103
"%s", khttps[KHTTP_200]);
104
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
105
"%s", kmimetypes[KMIME_APP_JSON]);
108
kjson_string_open(&req);
109
kjson_string_write("hello", 5, &req);
116
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .