Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if string is json parsable

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

}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #string #json #parsable
ADD COMMENT
Topic
Name
2+4 =