diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-07-24 07:43:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-24 07:43:33 -0400 |
commit | ba8f0da9de3677fd3b0c1d171f5d9bd3b2b8d2a8 (patch) | |
tree | 6265109dc0030ad6e3a3ae120ba7a4ca5fd1f4e3 | |
parent | Merge pull request #785 from thejan2009/floating-scroll-event-passthrough (diff) | |
parent | Put ipc command result json in an array (diff) | |
download | sway-ba8f0da9de3677fd3b0c1d171f5d9bd3b2b8d2a8.tar.gz sway-ba8f0da9de3677fd3b0c1d171f5d9bd3b2b8d2a8.tar.zst sway-ba8f0da9de3677fd3b0c1d171f5d9bd3b2b8d2a8.zip |
Merge pull request #787 from acrisci/bug/ipc-command-result-array
Put ipc command result json in an array
-rw-r--r-- | sway/commands.c | 5 |
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) { | |||
3657 | } | 3657 | } |
3658 | 3658 | ||
3659 | const char *cmd_results_to_json(struct cmd_results *results) { | 3659 | const char *cmd_results_to_json(struct cmd_results *results) { |
3660 | json_object *result_array = json_object_new_array(); | ||
3660 | json_object *root = json_object_new_object(); | 3661 | json_object *root = json_object_new_object(); |
3661 | json_object_object_add(root, "success", json_object_new_boolean(results->status == CMD_SUCCESS)); | 3662 | json_object_object_add(root, "success", json_object_new_boolean(results->status == CMD_SUCCESS)); |
3662 | if (results->input) { | 3663 | if (results->input) { |
@@ -3665,7 +3666,9 @@ const char *cmd_results_to_json(struct cmd_results *results) { | |||
3665 | if (results->error) { | 3666 | if (results->error) { |
3666 | json_object_object_add(root, "error", json_object_new_string(results->error)); | 3667 | json_object_object_add(root, "error", json_object_new_string(results->error)); |
3667 | } | 3668 | } |
3668 | const char *json = json_object_to_json_string(root); | 3669 | json_object_array_add(result_array, root); |
3670 | const char *json = json_object_to_json_string(result_array); | ||
3671 | free(result_array); | ||
3669 | free(root); | 3672 | free(root); |
3670 | return json; | 3673 | return json; |
3671 | } | 3674 | } |