summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2016-07-23 23:13:09 -0400
committerFurkan Sahin <furkan-dev@proton.me>2016-07-23 23:13:09 -0400
commit8b8e37385ea132bd9f2e4494569a0ba739b10983 (patch)
tree6265109dc0030ad6e3a3ae120ba7a4ca5fd1f4e3
parent105a630a87342d7932b10ad6f1aa34b749b99440 (diff)
Put ipc command result json in an array
For compatibility with i3, put the command result into an array. Returning multiple command results is still unsupported.
-rw-r--r--sway/commands.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 5cf93c53..ed561764 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -3657,6 +3657,7 @@ void free_cmd_results(struct cmd_results *results) {
}
const char *cmd_results_to_json(struct cmd_results *results) {
+ json_object *result_array = json_object_new_array();
json_object *root = json_object_new_object();
json_object_object_add(root, "success", json_object_new_boolean(results->status == CMD_SUCCESS));
if (results->input) {
@@ -3665,7 +3666,9 @@ const char *cmd_results_to_json(struct cmd_results *results) {
if (results->error) {
json_object_object_add(root, "error", json_object_new_string(results->error));
}
- const char *json = json_object_to_json_string(root);
+ json_object_array_add(result_array, root);
+ const char *json = json_object_to_json_string(result_array);
+ free(result_array);
free(root);
return json;
}