• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:name +full:- +full:pretty

1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) //
24 bool pretty; /* optional whitepace */ member
28 /* indentation for pretty print */
33 for (i = 0; i < self->depth; ++i) in jsonw_indent()
34 fputs(" ", self->out); in jsonw_indent()
37 /* end current line and indent if pretty printing */
40 if (!self->pretty) in jsonw_eol()
43 putc('\n', self->out); in jsonw_eol()
50 if (self->sep != '\0') in jsonw_eor()
51 putc(self->sep, self->out); in jsonw_eor()
52 self->sep = ','; in jsonw_eor()
60 putc('"', self->out); in jsonw_puts()
64 fputs("\\t", self->out); in jsonw_puts()
67 fputs("\\n", self->out); in jsonw_puts()
70 fputs("\\r", self->out); in jsonw_puts()
73 fputs("\\f", self->out); in jsonw_puts()
76 fputs("\\b", self->out); in jsonw_puts()
79 fputs("\\\\", self->out); in jsonw_puts()
82 fputs("\\\"", self->out); in jsonw_puts()
85 fputs("\\\'", self->out); in jsonw_puts()
88 putc(*str, self->out); in jsonw_puts()
90 putc('"', self->out); in jsonw_puts()
99 self->out = f; in jsonw_new()
100 self->depth = 0; in jsonw_new()
101 self->pretty = false; in jsonw_new()
102 self->sep = '\0'; in jsonw_new()
112 assert(self->depth == 0); in jsonw_destroy()
113 fputs("\n", self->out); in jsonw_destroy()
114 fflush(self->out); in jsonw_destroy()
121 self->pretty = on; in jsonw_pretty()
128 putc(c, self->out); in jsonw_begin()
129 ++self->depth; in jsonw_begin()
130 self->sep = '\0'; in jsonw_begin()
135 assert(self->depth > 0); in jsonw_end()
137 --self->depth; in jsonw_end()
138 if (self->sep != '\0') in jsonw_end()
140 putc(c, self->out); in jsonw_end()
141 self->sep = ','; in jsonw_end()
145 /* Add a JSON property name */
146 void jsonw_name(json_writer_t *self, const char *name) in jsonw_name() argument
150 self->sep = '\0'; in jsonw_name()
151 jsonw_puts(self, name); in jsonw_name()
152 putc(':', self->out); in jsonw_name()
153 if (self->pretty) in jsonw_name()
154 putc(' ', self->out); in jsonw_name()
164 vfprintf(self->out, fmt, ap); in jsonw_printf()
182 if (self->pretty) in jsonw_start_array()
183 putc(' ', self->out); in jsonw_start_array()
188 if (self->pretty && self->sep) in jsonw_end_array()
189 putc(' ', self->out); in jsonw_end_array()
190 self->sep = '\0'; in jsonw_end_array()
261 /* Basic name/value objects */
359 while (--argc) in main()