diff --git a/json_object.c b/json_object.c index 8d4d7d4..c5e72e4 100644 --- a/json_object.c +++ b/json_object.c @@ -377,7 +377,7 @@ static void indent(struct printbuf *pb, int level, int flags) /* json_object_object */ -static void json_object_object_to_json_string(struct json_object* jso, +static int json_object_object_to_json_string(struct json_object* jso, struct printbuf *pb, int level, int flags) @@ -421,6 +421,7 @@ static void json_object_object_to_json_string(struct json_object* jso, printbuf_memappend_no_nul(pb, /*{*/ " }", 2); else printbuf_memappend_no_nul(pb, /*{*/ "}", 1); + return 0; /* we need to keep compatible with the API */ } @@ -553,7 +554,7 @@ void json_object_object_del(struct json_object* jso, const char *key) /* json_object_boolean */ -static void json_object_boolean_to_json_string(struct json_object* jso, +static int json_object_boolean_to_json_string(struct json_object* jso, struct printbuf *pb, int level, int flags) @@ -562,6 +563,7 @@ static void json_object_boolean_to_json_string(struct json_object* jso, printbuf_memappend_no_nul(pb, "true", 4); else printbuf_memappend_no_nul(pb, "false", 5); + return 0; /* we need to keep compatible with the API */ } struct json_object* json_object_new_boolean(json_bool b) @@ -596,12 +598,13 @@ json_bool json_object_get_boolean(struct json_object *jso) /* json_object_int */ -static void json_object_int_to_json_string(struct json_object* jso, +static int json_object_int_to_json_string(struct json_object* jso, struct printbuf *pb, int level, int flags) { sprintbuf(pb, "%" PRId64, jso->o.c_int64); + return 0; /* we need to keep compatible with the API */ } struct json_object* json_object_new_int(int32_t i) @@ -688,7 +691,7 @@ int64_t json_object_get_int64(struct json_object *jso) /* json_object_double */ -static void json_object_double_to_json_string(struct json_object* jso, +static int json_object_double_to_json_string(struct json_object* jso, struct printbuf *pb, int level, int flags) @@ -726,6 +729,7 @@ static void json_object_double_to_json_string(struct json_object* jso, size = p-buf; } printbuf_memappend_no_nul(pb, buf, size); + return 0; /* we need to keep compatible with the API */ } struct json_object* json_object_new_double(double d) @@ -756,11 +760,12 @@ struct json_object* json_object_new_double_s(double d, const char *ds) return jso; } -void json_object_userdata_to_json_string(struct json_object *jso, +int json_object_userdata_to_json_string(struct json_object *jso, struct printbuf *pb, int level, int flags) { int userdata_len = strlen((const char *)jso->_userdata); printbuf_memappend_no_nul(pb, (const char *)jso->_userdata, userdata_len); + return 0; /* we need to keep compatible with the API */ } void json_object_free_userdata(struct json_object *jso, void *userdata) @@ -820,7 +825,7 @@ double json_object_get_double(struct json_object *jso) /* json_object_string */ -static void json_object_string_to_json_string(struct json_object* jso, +static int json_object_string_to_json_string(struct json_object* jso, struct printbuf *pb, int level, int flags) @@ -828,6 +833,7 @@ static void json_object_string_to_json_string(struct json_object* jso, printbuf_memappend_no_nul(pb, "\"", 1); json_escape_str(pb, get_string_component(jso), jso->o.c_string.len); printbuf_memappend_no_nul(pb, "\"", 1); + return 0; /* we need to keep compatible with the API */ } static void json_object_string_delete(struct json_object* jso) @@ -914,7 +920,7 @@ int json_object_get_string_len(struct json_object *jso) /* json_object_array */ -static void json_object_array_to_json_string(struct json_object* jso, +static int json_object_array_to_json_string(struct json_object* jso, struct printbuf *pb, int level, int flags) @@ -954,6 +960,7 @@ static void json_object_array_to_json_string(struct json_object* jso, printbuf_memappend_no_nul(pb, " ]", 2); else printbuf_memappend_no_nul(pb, "]", 1); + return 0; /* we need to keep compatible with the API */ } static void json_object_array_entry_free(void *data) diff --git a/json_object.h b/json_object.h index ee6b0b2..67137d8 100644 --- a/json_object.h +++ b/json_object.h @@ -128,7 +128,7 @@ typedef void (json_object_delete_fn)(struct json_object *jso, void *userdata); /** * Type of a custom serialization function. See json_object_set_serializer. */ -typedef void (json_object_to_json_string_fn)(struct json_object *jso, +typedef int (json_object_to_json_string_fn)(struct json_object *jso, struct printbuf *pb, int level, int flags);