Javascript String isJSON()

Description

Javascript String isJSON()


String.prototype.isJSON = function(){
    try {/*w  w w .  j  ava 2 s  . c o m*/
        var o = JSON.parse(this);
     if (o && typeof o === "object") {
            return o;
        }
    }
    catch (e) { }
    return false;
};


String.prototype.replaceAll = function(target, replacement) {
  return this.split(target).join(replacement);
};



PreviousNext

Related