From fa4219714606a9d45bba59c1f84c3ee77dbdbdc7 Mon Sep 17 00:00:00 2001 From: Matt Porter Date: Tue, 10 Jul 2018 11:53:10 -0400 Subject: Return technology and service response arrays in a nested object The binding currently just attachs a json array to the response object. To make parsing of the reply payload simpler, always attach a json object with the array added to the "values" key. Bug-AGL: SPEC-1540 Change-Id: I1753ec4a2d1c0186e807db004d58d2016c0e8e96 Signed-off-by: Matt Porter --- binding/network-connman.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/binding/network-connman.c b/binding/network-connman.c index a9e0b74..0e51fa2 100644 --- a/binding/network-connman.c +++ b/binding/network-connman.c @@ -383,7 +383,7 @@ json_object *connman_get_properties(struct network_state *ns, const gchar *path = NULL; const gchar *key = NULL; const gchar *basename; - json_object *jprop = NULL, *jresp = NULL, *jtype = NULL; + json_object *jarray = NULL, *jprop = NULL, *jresp = NULL, *jtype = NULL; gboolean is_config; pi = connman_get_property_info(access_type, error); @@ -421,8 +421,11 @@ json_object *connman_get_properties(struct network_state *ns, g_variant_unref(reply); jresp = jprop; } else { - if (!type_arg) - jresp = json_object_new_array(); + if (!type_arg) { + jarray = json_object_new_array(); + jresp = json_object_new_object(); + json_object_object_add(jresp, "values", jarray); + } g_variant_get(reply, "(a(oa{sv}))", &array); while (g_variant_iter_loop(array, "(oa{sv})", &path, &array2)) { @@ -448,7 +451,7 @@ json_object *connman_get_properties(struct network_state *ns, if (!type_arg) { json_object_object_add(jtype, "properties", jprop); - json_object_array_add(jresp, jtype); + json_object_array_add(jarray, jtype); } } g_variant_iter_free(array); -- cgit 1.2.3-korg