1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2026-03-02 04:09:18 +00:00

refactor: introduced convenience functions for json_writer

This commit is contained in:
Falk Werner
2020-07-11 00:34:07 +02:00
parent 5cdeb6d759
commit e0b01cfe19
5 changed files with 72 additions and 26 deletions

View File

@@ -61,11 +61,8 @@ static char * wfp_jsonrpc_request_create(
struct wfp_json_writer * writer = wfp_impl_json_writer_create(128, LWS_PRE);
wfp_impl_json_writer_object_begin(writer);
wfp_impl_json_writer_object_key(writer, "method");
wfp_impl_json_writer_write_string(writer, method);
wfp_impl_json_writer_object_key(writer, "params");
wfp_impl_json_writer_array_begin(writer);
wfp_impl_json_writer_object_write_string(writer, "method", method);
wfp_impl_json_writer_object_begin_array(writer, "params");
for (char const * param_type = param_info; '\0' != *param_type; param_type++)
{
switch(*param_type)
@@ -98,8 +95,7 @@ static char * wfp_jsonrpc_request_create(
if (0 != id)
{
wfp_impl_json_writer_object_key(writer, "id");
wfp_impl_json_writer_write_int(writer, id);
wfp_impl_json_writer_object_write_int(writer, "id", id);
}
wfp_impl_json_writer_object_end(writer);