Skip to content

Commit ca6721c

Browse files
committed
Attempt to parse the JSON to see if it is already well formed
1 parent ec0c7b6 commit ca6721c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/lib/parameter_hunter.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ var parameter_hunter = function () {
6262
var values = [];
6363
var wrapper;
6464

65+
// attempt to parse the data incase it is already well formed JSON
66+
try {
67+
paramStringWellFormed = JSON.stringify(JSON.parse(pString));
68+
return paramStringWellFormed;
69+
} catch(err) {
70+
console.log('Not valid JSON - will attempt to parse manually...');
71+
}
72+
6573
//replace all escaped double-quotes with escaped unicode
6674
paramString = paramString.replace(/\\"/g, '\\u0022');
6775

0 commit comments

Comments
 (0)