if (/^[],:{}s]*$/.test(text.replace(/["/bfnrtu]/g, '@'). replace(/"[^" ]*"|true|false|null|-?d+(?:.d*)?(?:[eE][+-]?d+)?/g, ']'). replace(/(?:^|:|,)(?:s*[)+/g, ''))) { //the json is ok }else{ //the json is not ok }