<?php
$jsontest = '{"name": "yasamin", "age": 25, "city": "shiraz"}';
function isValidJson($str)
{
json_decode($str);
return (json_last_error() == JSON_ERROR_NONE);
}
if (isValidJson($jsontest)) {
echo "The JSON string is valid
";
} else {
echo "The JSON string is invalid
";
}