Answers for "how to check if string is JSON string or not in JS"

3

javascript check if string is json parsable

var isJsonParsable = string => {
    try {
        JSON.parse(string);
    } catch (e) {
        return false;
    }
    return true;
}
Posted by: Guest on April-28-2020
1

check if the data can be parsed javascript

function isJson(str) {
            try {
                return JSON.parse(str);
            } catch (e) {
                return false;
            }
        }
Posted by: Guest on July-24-2020

Code answers related to "how to check if string is JSON string or not in JS"

Code answers related to "Javascript"

Browse Popular Code Answers by Language