-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.c
More file actions
29 lines (23 loc) · 998 Bytes
/
example.c
File metadata and controls
29 lines (23 loc) · 998 Bytes
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
#include <stdlib.h>
#include <stdio.h>
#include <static-json-builder.h>
int main(void)
{
Json json = JsonObject( /* { */
JsonProp("items", JsonArray( /* "items": [ */
JsonNull(), /* null, */
JsonBool(true), /* true, */
JsonInt(1), /* 1, */
JsonString("hello") /* "hello", */
)) /* ], */
); /* }, */
char *string = NULL;
char *buffer = malloc(json_stingified_size(json));
string = json_stringify(json);
json_stringify_into_buffer(json, buffer);
printf("%s\n", string); /* {"items":[null,true,1,"hello"]} */
printf("%s\n", buffer); /* {"items":[null,true,1,"hello"]} */
free(string);
free(buffer);
return 0;
}