24 #ifndef UJSON_WRITER_H
25 #define UJSON_WRITER_H
36 void (*
err_print)(
void *err_print_priv,
const char *line);
53 #define UJSON_WRITER_INIT(vout, vout_priv) { \
54 .err_print = UJSON_ERR_PRINT, \
55 .err_print_priv = UJSON_ERR_PRINT_PRIV, \
57 .out_priv = vout_priv \
91 return !!
self->err[0];
int(* out)(struct ujson_writer *self, const char *buf, size_t buf_size)
void(* err_print)(void *err_print_priv, const char *line)
Common JSON reader/writer definitions.
#define UJSON_RECURSION_MAX
Maximal recursion depth allowed.
#define UJSON_ERR_MAX
Maximal error message length.
int ujson_arr_finish(ujson_writer *self)
Finishes a JSON array.
int ujson_int_add(ujson_writer *self, const char *id, long val)
Adds an integer value.
int ujson_str_add(ujson_writer *self, const char *id, const char *str)
Adds a string value.
static int ujson_writer_err(ujson_writer *self)
Returns true if writer error happened.
ujson_writer * ujson_writer_file_open(const char *path)
Allocates a JSON file writer.
int ujson_null_add(ujson_writer *self, const char *id)
Adds a null value.
int ujson_arr_start(ujson_writer *self, const char *id)
Starts a JSON array.
int ujson_writer_finish(ujson_writer *self)
Finalizes json writer.
int ujson_bool_add(ujson_writer *self, const char *id, int val)
Adds a bool value.
int ujson_writer_file_close(ujson_writer *self)
Closes and frees a JSON file writer.
int ujson_obj_finish(ujson_writer *self)
Finishes a JSON object.
int ujson_float_add(ujson_writer *self, const char *id, double val)
Adds a float value.
int ujson_obj_start(ujson_writer *self, const char *id)
Starts a JSON object.