title: How to check if it's a string or json
body: <p>I have a json string that is converted from object by JSON.Stringify function.</p>
  
  <p>I'd like to know if it's json string or just a regular string.</p>
  
  <p>Is there any function like "isJson()" to check if it's json or not?</p>
  
  <p>I'd like to use the function when I use local storage like the code below.</p>
  
  <p>Thank you in advance!!</p>
  
  <pre><code>var Storage = function(){}
  
  Storage.prototype = {
  
    setStorage: function(key, data){
  
      if(typeof data == 'object'){
  
        data = JSON.stringify(data);
        localStorage.setItem(key, data);     
  
      } else {
        localStorage.setItem(key, data);
      }
  
    },
  
  
    getStorage: function(key){
  
      var data = localStorage.getItem(key);
  
      if(isJson(data){ // is there any function to check if the argument is json or string?
  
        data = JSON.parse(data);
        return data;
  
      } else {
  
        return data;
      }
  
    }
  
  }
  
  var storage = new Storage();
  
  storage.setStorage('test', {x:'x', y:'y'});
  
  console.log(storage.getStorage('test'));
  </code></pre>