From 8bec06d41035de5cba0c846693f6c08c686f849b Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Fri, 29 Jun 2018 09:46:01 +0900 Subject: Fix json format error Fix the followings * The response format of getListMainConnections is strange * Fix typo of getListMainSources Change-Id: I2a42f7feb6a9e33f293f74a9a7770428608e2767 Signed-off-by: Kazumasa Mitsunari --- src/soundmanager.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/soundmanager.c b/src/soundmanager.c index cb2815d..9d72547 100644 --- a/src/soundmanager.c +++ b/src/soundmanager.c @@ -257,17 +257,16 @@ void getListMainConnections(struct afb_req request) if(!SEND_RESULT(ec, request)) return; /* create response */ - struct json_object *array_res = json_object_new_array(); + struct json_object *response = json_object_new_object(); gsize size = g_variant_n_children(mainConnectionList); AFB_DEBUG("mainConnectionList size is %u",(uint16_t)size); - struct json_object *verb_obj = json_object_new_object(); - sm_add_object_to_json_object_func(verb_obj, __FUNCTION__, 0); - json_object_array_add(array_res, verb_obj); + sm_add_object_to_json_object_func(response, __FUNCTION__, 0); if(size <= 0) { AFB_NOTICE( "mainConnectionList size is 0"); } else{ + struct json_object *array_res = json_object_new_array(); for(int i = 0; i < size; ++i) { guint16 mcid, srcid, sinkid; @@ -287,9 +286,10 @@ void getListMainConnections(struct afb_req request) ); json_object_array_add(array_res,res_obj); } + json_object_object_add(response, "connections", array_res); } - AFB_DEBUG("json object :%s:",json_object_to_json_string(array_res)); - afb_req_success(request, array_res, "Success to get main connection list"); + AFB_DEBUG("json object :%s:",json_object_to_json_string(response)); + afb_req_success(request, response, "Success to get main connection list"); } void getListMainSources(struct afb_req request) @@ -337,7 +337,7 @@ void getListMainSources(struct afb_req request) json_object_array_add(array_res,res_obj); g_variant_unref(child); } - json_object_object_add(response, "sinks", array_res); + json_object_object_add(response, "sources", array_res); } afb_req_success(request, response, "Success to get main source list"); g_variant_unref(mainSourceList); @@ -1222,4 +1222,4 @@ int sm_init() void onevent(const char *event, struct json_object *object) { AFB_NOTICE("on_event %s", event); -} \ No newline at end of file +} -- cgit 1.2.3-korg