blob: f9442ada1a2997f6f635badaade652c1d1b12637 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/* A minimal JSON writer. No parser: we only ever emit. */
#ifndef SLOSH_JSON_H
#define SLOSH_JSON_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef struct {
char *buf;
size_t len, cap;
bool need_comma;
} json_t;
void json_init(json_t *j);
void json_free(json_t *j);
void json_obj_open(json_t *j, const char *key); /* key may be NULL in arrays */
void json_obj_close(json_t *j);
void json_arr_open(json_t *j, const char *key);
void json_arr_close(json_t *j);
void json_str(json_t *j, const char *key, const char *val, size_t len);
void json_int(json_t *j, const char *key, long long val);
void json_bool(json_t *j, const char *key, bool val);
void json_null(json_t *j, const char *key);
#endif /* SLOSH_JSON_H */
|