X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=plugins%2Fsamples%2FSamplePost.c;h=e5a7235f8b7e207d3733f038c443a9808ea002fe;hb=56f9ef4581d567248b6f83a3b15f39a0aca42895;hp=aab54e91f7117e9f44d878fb1c3e08350f8c98c0;hpb=c0453c34a58aac8150300ab829149a0ca4d9e5ee;p=src%2Fapp-framework-binder.git diff --git a/plugins/samples/SamplePost.c b/plugins/samples/SamplePost.c index aab54e91..e5a7235f 100644 --- a/plugins/samples/SamplePost.c +++ b/plugins/samples/SamplePost.c @@ -25,26 +25,11 @@ #include "afb-req-itf.h" -static int fillargs(json_object *args, struct afb_arg arg) -{ - json_object *obj; - - obj = json_object_new_object(); - json_object_object_add (obj, "value", json_object_new_string(arg.value)); - json_object_object_add (obj, "size", json_object_new_int64((int64_t)arg.size)); - json_object_object_add (obj, "is_file", json_object_new_boolean(arg.is_file)); - json_object_object_add (args, arg.name && *arg.name ? arg.name : "", obj); - return 1; /* continue to iterate */ -} - // Sample Generic Ping Debug API static void getPingTest(struct afb_req request) { static int pingcount = 0; - json_object *query; - - query = json_object_new_object(); - afb_req_iterate(request, (void*)fillargs, query); + json_object *query = afb_req_json(request); afb_req_success_f(request, query, "Ping Binder Daemon count=%d", ++pingcount); } @@ -52,12 +37,9 @@ static void getPingTest(struct afb_req request) // With content-type=json data are directly avaliable in request->post->data static void GetJsonByPost (struct afb_req request) { - json_object* jresp; - json_object *query; struct afb_arg arg; - - query = json_object_new_object(); - afb_req_iterate(request, (void*)fillargs, query); + json_object* jresp; + json_object *query = afb_req_json(request); arg = afb_req_get(request, ""); jresp = arg.value ? json_tokener_parse(arg.value) : NULL;