Check json in php

When getting in JSON for a request you first going to need to check whether the incoming content is actually valid JSON. Unfortunately there is no PHP function for that. Here is a little utility function for it:

/**
 * Is valid JSON
 * 
 * @param string $jsonString JSON string
 *
 * @return bool
 */
function isValidJson($jsonString)
{
    json_decode($jsonString);
    return (json_last_error() == JSON_ERROR_NONE);
}