Javascript – check if a string is a valid JSON

function IsJson(myString) {
    try {
        JSON.parse(myString);
    } 
    catch (err) {
        return false;
    }
    return true;
}

Leave a Comment

Your email address will not be published. Required fields are marked *