title: Initialize a JavaScript object using JSON
body: <p>I want to do the following</p>
  
  <pre><code>var my_json = {
      a : 'lemon',
      b : 1
  }
  
  function obj(json){
      this.a = 'apple';
      this.b = 0;
      this.c = 'other default';
  }
  </code></pre>
  
  <p>after assigning</p>
  
  <pre><code>var instance = obj(my_json)
  </code></pre>
  
  <p>I want to get</p>
  
  <pre><code>instance.a == 'lemon'
  </code></pre>