mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Merge pull request #787 from acrisci/bug/ipc-command-result-array
Put ipc command result json in an array
This commit is contained in:
		
						commit
						ba8f0da9de
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
					@ -3657,6 +3657,7 @@ void free_cmd_results(struct cmd_results *results) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char *cmd_results_to_json(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 *root = json_object_new_object();
 | 
				
			||||||
	json_object_object_add(root, "success", json_object_new_boolean(results->status == CMD_SUCCESS));
 | 
						json_object_object_add(root, "success", json_object_new_boolean(results->status == CMD_SUCCESS));
 | 
				
			||||||
	if (results->input) {
 | 
						if (results->input) {
 | 
				
			||||||
| 
						 | 
					@ -3665,7 +3666,9 @@ const char *cmd_results_to_json(struct cmd_results *results) {
 | 
				
			||||||
	if (results->error) {
 | 
						if (results->error) {
 | 
				
			||||||
		json_object_object_add(root, "error", json_object_new_string(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);
 | 
						free(root);
 | 
				
			||||||
	return json;
 | 
						return json;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue