diff options
author | Matt Porter <mporter@konsulko.com> | 2018-07-10 11:53:10 -0400 |
---|---|---|
committer | Matt Porter <mporter@konsulko.com> | 2018-07-10 11:53:10 -0400 |
commit | fa4219714606a9d45bba59c1f84c3ee77dbdbdc7 (patch) | |
tree | 4ca0cf680cc06f94c9b229f5b998168a82333f6d /binding | |
parent | bbb2d212c31c74410766ed7ee49e49c892491718 (diff) |
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 <mporter@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r-- | binding/network-connman.c | 11 |
1 files 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); |