diff --git a/.gitignore b/.gitignore index 491dd379..b9637696 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ build.number src/.* *.prefs build.secret.properties -src/tests/easyXDM.debug.js \ No newline at end of file +src/tests/easyXDM.debug.js +.idea/ diff --git a/src/Core.js b/src/Core.js index 6fb1b3c9..bdebd675 100644 --- a/src/Core.js +++ b/src/Core.js @@ -432,6 +432,21 @@ var getJSON = function(){ }; } } + + if (typeof JSON != "undefined" && typeof JSON.encode === "function" && JSON.encode(obj).replace((/\s/g), "") === json) { + // this is a working stringify method + cached.stringify = JSON.encode; + } + + if (typeof JSON.decode === 'function') { + obj = JSON.decode(json); + if (obj.a && obj.a.length === 3 && obj.a[2] === 3) { + // this is a working parse method + cached.parse = function(str){ + return JSON.decode(str); + }; + } + } if (cached.stringify && cached.parse) { // Only memoize the result if we have valid instance