if json valide js

JavaScript
function IsJsonString(str) {
    try {
        JSON.parse(str);
    } catch (e) {
        return false;
    }
    return true;
}
Source

Also in JavaScript: