mirror of
https://github.com/json-c/json-c.git
synced 2026-03-30 02:19:06 +08:00
clang-format the files
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
#include "json.h"
|
||||
#include "printbuf.h"
|
||||
|
||||
struct myinfo {
|
||||
struct myinfo
|
||||
{
|
||||
int value;
|
||||
};
|
||||
|
||||
@@ -17,10 +18,7 @@ static void freeit(json_object *jso, void *userdata)
|
||||
// Don't actually free anything here, the userdata is stack allocated.
|
||||
freeit_was_called = 1;
|
||||
}
|
||||
static int custom_serializer(struct json_object *o,
|
||||
struct printbuf *pb,
|
||||
int level,
|
||||
int flags)
|
||||
static int custom_serializer(struct json_object *o, struct printbuf *pb, int level, int flags)
|
||||
{
|
||||
sprintbuf(pb, "Custom Output");
|
||||
return 0;
|
||||
@@ -39,10 +37,11 @@ int main(int argc, char **argv)
|
||||
|
||||
printf("my_object.to_string(standard)=%s\n", json_object_to_json_string(my_object));
|
||||
|
||||
struct myinfo userdata = { .value = 123 };
|
||||
struct myinfo userdata = {.value = 123};
|
||||
json_object_set_serializer(my_object, custom_serializer, &userdata, freeit);
|
||||
|
||||
printf("my_object.to_string(custom serializer)=%s\n", json_object_to_json_string(my_object));
|
||||
printf("my_object.to_string(custom serializer)=%s\n",
|
||||
json_object_to_json_string(my_object));
|
||||
|
||||
printf("Next line of output should be from the custom freeit function:\n");
|
||||
freeit_was_called = 0;
|
||||
@@ -60,7 +59,8 @@ int main(int argc, char **argv)
|
||||
json_object_set_serializer(my_object, custom_serializer, &userdata, freeit);
|
||||
json_object_get(my_object);
|
||||
json_object_put(my_object);
|
||||
printf("my_object.to_string(custom serializer)=%s\n", json_object_to_json_string(my_object));
|
||||
printf("my_object.to_string(custom serializer)=%s\n",
|
||||
json_object_to_json_string(my_object));
|
||||
printf("Next line of output should be from the custom freeit function:\n");
|
||||
|
||||
freeit_was_called = 0;
|
||||
|
||||
Reference in New Issue
Block a user