[asterisk-commits] manager: Fix GetConfigJSON returning invalid JSON (asterisk[11])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 5 07:16:09 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: manager: Fix GetConfigJSON returning invalid JSON
......................................................................


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 [].

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

Change-Id: Ibbe93c6a227dff14d4a54b0d152341857bcf6ad8
---
M main/manager.c
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Matt Jordan: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved



diff --git a/main/manager.c b/main/manager.c
index d5e3273..19c00b3 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -2871,7 +2871,7 @@
 
 		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 @@
 			astman_append(s, "\"");
 			comma2 = 1;
 		}
-		astman_append(s, "]");
+		astman_append(s, "}");
 	}
 	astman_append(s, "}\r\n\r\n");
 

-- 
To view, visit https://gerrit.asterisk.org/1372
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibbe93c6a227dff14d4a54b0d152341857bcf6ad8
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Ivan Poddubny <ivan.poddubny at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list