]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
manager: Fix GetConfigJSON returning invalid JSON 72/1372/1
authorIvan Poddubny <ivan.poddubny@gmail.com>
Sat, 3 Oct 2015 11:27:27 +0000 (14:27 +0300)
committerIvan Poddubny <ivan.poddubny@gmail.com>
Sat, 3 Oct 2015 12:45:59 +0000 (15:45 +0300)
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 [].

ASTERISK-25391 #close
Reported by: Bojan Nemčić

Change-Id: Ibbe93c6a227dff14d4a54b0d152341857bcf6ad8

main/manager.c

index d5e3273f5ecde63562687301566a443ac29e94e1..19c00b35bd9be9ff26bf492261e6a081a55ea768 100644 (file)
@@ -2871,7 +2871,7 @@ static int action_getconfigjson(struct mansession *s, const struct message *m)
 
                astman_append(s, "%s\"", comma1 ? "," : "");
                astman_append_json(s, category);
-               astman_append(s, "\":[");
+               astman_append(s, "\":{");
                comma1 = 1;
                for (v = ast_variable_browse(cfg, category); v; v = v->next) {
                        astman_append(s, "%s\"", comma2 ? "," : "");
@@ -2881,7 +2881,7 @@ static int action_getconfigjson(struct mansession *s, const struct message *m)
                        astman_append(s, "\"");
                        comma2 = 1;
                }
-               astman_append(s, "]");
+               astman_append(s, "}");
        }
        astman_append(s, "}\r\n\r\n");