/ Published in: PHP

Check if a string it's json encoded using regular expressions
Thanks to Jens Anders Bakke for his mootools code published in webfreak.no
http://webfreak.no/wp/2007/09/07/jsontest-for-mootools/
Thanks to Jens Anders Bakke for his mootools code published in webfreak.no
http://webfreak.no/wp/2007/09/07/jsontest-for-mootools/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Comprueba si una cadena es json o no. // 19/01/2011 Jatubio - http://webfreak.no/wp/2007/09/07/jsontest-for-mootools/ function is_json($string) { return !empty($string) && is_string($string) && preg_match('/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/',$string); }
Comments
