title: convert mongodb object to javascript object
body: <p>I pass a config file to another node.js module when starting it. The config file contain the following json:</p>
  
  <pre><code>    "resolution": {
        "activated": true,
        "types": [
        {"of": 23}
        ]
      }
  </code></pre>
  
  <p>When I print the received types array in the called node.js module, it looks like</p>
  
  <pre><code>console.log('types array: '+ this.config.resolution.types) 
  //output
  types array: [object Object]
  </code></pre>
  
  <p>if I tried to print the text by using <code>JSON.stringify()</code>, I get the following result</p>
  
  <pre><code>[{"of":23}]
  </code></pre>
  
  <p>My problem start when I try to replace the types array with a list retried from a mongodb database. my code looks like:</p>
  
  <p>"resolution": {
        "activated": true,
        "types": [
        savedTypes
        ]
      }</p>
  
  <p>Now when I print the received types config, it looks like this: </p>
  
  <pre><code>types array: { _id: 5ab9fe8fd1f64303cd98f122, of: 23, __v: 0 }
  </code></pre>
  
  <p>and the called node module is not working properly with this config. How can I cast this to an object? I tried to use</p>
  
  <pre><code>JSON.parse(savedTypes)
  </code></pre>
  
  <p>and get the error</p>
  
  <pre><code>SyntaxError: Unexpected token _ in JSON at position 2
  </code></pre>