function isJSON(str) {
        try {
            JSON.parse(str)
        }
        catch {
            return false
        }
      	return true
      }
      var str = "JavaScript"
      console.log(isJSON(str))
      
      Javascript language logo

      string json or not

      Check is the string is JSON or not in JavaScript

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.