Skip to content

Instantly share code, notes, and snippets.

@luislobo14rap
Created July 30, 2018 19:30
Show Gist options
  • Save luislobo14rap/8ccba74e918943b8e3c083bbea20f1ec to your computer and use it in GitHub Desktop.
Save luislobo14rap/8ccba74e918943b8e3c083bbea20f1ec to your computer and use it in GitHub Desktop.
// json-prototypes.js v1
// isJSON.js v1
function isJSON(json) {
let realJSON = {};
if (json.constructor == realJSON.constructor) {
return true;
};
return false;
};
Object.prototype.isJSON = function() {
return isJSON(this);
};
String.prototype.isJSON = function() {
return false;
};
// isEmptyJSON.js v1
function isEmptyJSON(json) {
let realJSON = {};
if (json.constructor == realJSON.constructor) {
let stringifyJSON = JSON.stringify(json);
if (stringifyJSON == '{}') {
return true;
};
};
return false;
};
Object.prototype.isEmptyJSON = function() {
return isEmptyJSON(this);
};
String.prototype.isEmptyJSON = function() {
return false;
};
// json-prototypes.min.js v1
function isJSON(a){if(a.constructor=={}.constructor)return!0;return!1}Object.prototype.isJSON=function(){return isJSON(this)},String.prototype.isJSON=function(){return!1};function isEmptyJSON(a){if(a.constructor=={}.constructor){let c=JSON.stringify(a);if('{}'==c)return!0}return!1}Object.prototype.isEmptyJSON=function(){return isEmptyJSON(this)},String.prototype.isEmptyJSON=function(){return!1};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment