Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if string is a valid json string

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 #valid #json #string
ADD COMMENT
Topic
Name
1+7 =