blob: 932290172d8439669a0dd38f4636a48881abc3fe (
plain)
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
29
30
31
32
|
#ifndef DUCC_JSON_H
#define DUCC_JSON_H
struct JsonBuilder;
typedef struct JsonBuilder JsonBuilder;
JsonBuilder* jsonbuilder_new();
const char* jsonbuilder_get_output(JsonBuilder* b);
void jsonbuilder_object_start(JsonBuilder* b);
void jsonbuilder_object_end(JsonBuilder* b);
void jsonbuilder_object_member_start(JsonBuilder* b, const char* key);
void jsonbuilder_object_member_end(JsonBuilder* b);
void jsonbuilder_array_start(JsonBuilder* b);
void jsonbuilder_array_end(JsonBuilder* b);
void jsonbuilder_array_element_start(JsonBuilder* b);
void jsonbuilder_array_element_end(JsonBuilder* b);
void jsonbuilder_null(JsonBuilder* b);
void jsonbuilder_boolean(JsonBuilder* b, bool value);
void jsonbuilder_integer(JsonBuilder* b, int value);
void jsonbuilder_string(JsonBuilder* b, const char* value);
#define JSON_DUMP(x, f) \
do { \
JsonBuilder* _builder = jsonbuilder_new(); \
f(_builder, (x)); \
fprintf(stderr, "%s\n", jsonbuilder_get_output(_builder)); \
} while (0)
#endif
|