Skip to content

Instantly share code, notes, and snippets.

@amadeus
Created September 29, 2011 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amadeus/1251192 to your computer and use it in GitHub Desktop.
Save amadeus/1251192 to your computer and use it in GitHub Desktop.
A simple way to parse JSON.
(function(){
if (!this.JSON) this.JSON = {};
var decode = window.JSON.parse || function(str){
return window.eval('(' + str + ')');
};
this.JSON.decode = function(str){
var json = null;
try {
json = decode(str);
} catch(e) {}
return json;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment