diff options
author | Ivan Poddubny <ivan.poddubny@gmail.com> | 2015-10-03 14:27:27 +0300 |
---|---|---|
committer | Ivan Poddubny <ivan.poddubny@gmail.com> | 2015-10-03 08:09:21 -0500 |
commit | 74635b56381c5facaf5b5a6d12a5aa39abf10a0e (patch) | |
tree | f4ca50ed08fdcc8723175c4e2d7bc1ae10fd6ed7 /main | |
parent | b39e92f036188664aefa494a798253f4f78d11f4 (diff) |
manager: Fix GetConfigJSON returning invalid JSON
When GetConfigJSON was introduced back in 1.6, it returned each
section as an array of strings: ["key=value", "key2=value2"].
Afterwards, it was changed a few times and became
["key": "value", "key2": "value2"], which is not a correct JSON.
This patch fixes that by constructing a JSON object {} instead of
an array [].
Also, the keys "istemplate" and "tempates" that are used to
indicate templates and their inherited categories are now wrapped in
quotes.
ASTERISK-25391 #close
Reported by: Bojan Nemčić
Change-Id: Ibbe93c6a227dff14d4a54b0d152341857bcf6ad8
Diffstat (limited to 'main')
-rw-r--r-- | main/manager.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/main/manager.c b/main/manager.c index 035115fc4..75b1d4d48 100644 --- a/main/manager.c +++ b/main/manager.c @@ -3469,18 +3469,18 @@ static int action_getconfigjson(struct mansession *s, const struct message *m) category_name = ast_category_get_name(cur_category); astman_append(s, "%s\"", comma1 ? "," : ""); astman_append_json(s, category_name); - astman_append(s, "\":["); + astman_append(s, "\":{"); comma1 = 1; if (ast_category_is_template(cur_category)) { - astman_append(s, "istemplate:1"); + astman_append(s, "\"istemplate\":1"); comma2 = 1; } if ((templates = ast_category_get_templates(cur_category)) && ast_str_strlen(templates) > 0) { astman_append(s, "%s", comma2 ? "," : ""); - astman_append(s, "templates:\"%s\"", ast_str_buffer(templates)); + astman_append(s, "\"templates\":\"%s\"", ast_str_buffer(templates)); ast_free(templates); comma2 = 1; } @@ -3494,7 +3494,7 @@ static int action_getconfigjson(struct mansession *s, const struct message *m) comma2 = 1; } - astman_append(s, "]"); + astman_append(s, "}"); } astman_append(s, "}\r\n\r\n"); |