Created
July 30, 2018 19:30
-
-
Save luislobo14rap/8ccba74e918943b8e3c083bbea20f1ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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