Search the blog

This function validates a string and returns true if it is valid JSON, false otherwise.

function isValidJSON($data) {

    $data = json_decode($data);
	
    return (json_last_error() === JSON_ERROR_NONE);
	
}
Tim Bennett is a web designer and developer. He has a First Class Honours degree in Computing from Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.