Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ build.number
src/.*
*.prefs
build.secret.properties
src/tests/easyXDM.debug.js
src/tests/easyXDM.debug.js
.idea/
15 changes: 15 additions & 0 deletions src/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down