From de049a3d79628d5cbf68dcca88bbf0183932e23c Mon Sep 17 00:00:00 2001 From: Jean-Michel Simard Date: Tue, 11 Dec 2018 09:34:53 -0500 Subject: [PATCH 1/2] Fix for issue #6 --- src/JSONC.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JSONC.js b/src/JSONC.js index 8372433..26e4e03 100644 --- a/src/JSONC.js +++ b/src/JSONC.js @@ -236,7 +236,7 @@ str = JSON.stringify(jsonCopy); for (sKey in oKeys) { if (oKeys.hasOwnProperty(sKey)) { - str = str.replace(new RegExp('"' + sKey + '"', 'g'), '"' + oKeys[sKey] + '"'); + str = str.replace(new RegExp('(?:"'+sKey+'"):', 'g'), '"' + oKeys[sKey] + '":'); } } return str; From 56d700defe115f721e9dc0ecb9c6212fb551029b Mon Sep 17 00:00:00 2001 From: Jean-Michel Simard Date: Tue, 11 Dec 2018 15:13:06 -0500 Subject: [PATCH 2/2] Fix for issue #6 (_compressOther) --- src/JSONC.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JSONC.js b/src/JSONC.js index 26e4e03..d2719ea 100644 --- a/src/JSONC.js +++ b/src/JSONC.js @@ -202,7 +202,7 @@ for (nIndex = 0; nIndex < nLenKeys; nIndex++) { aKey = aKeys[nIndex]; - str = str.replace(new RegExp(escapeRegExp('"' + aKey[1] + '"'), 'g'), '"' + aKey[0] + '"'); + str = str.replace(new RegExp('(?:"'+escapeRegExp(aKey[1])+'"):', 'g'), '"' + aKey[0] + '":'); } obj = JSON.parse(str); obj._ = oKeys;