title: JSON object returns undefined value
body: <p>I am receiving a JSON object from a http call and I am trying to extract values from it. 
  JSON object contains: </p>
  
  <pre><code>data:{"userid":"007", "role":"spy"}
  </code></pre>
  
  <p>I use the following code to assign <strong>role</strong> property to another variable followed by some console log checks:</p>
  
  <pre><code>    currentUserRole = data.role;    
      console.log("type of data: "+typeof(data));
      console.log("data: "+JSON.stringify(data));
      console.log("user role: "+currentUserRole);
  </code></pre>
  
  <p>The logs produce:</p>
  
  <pre><code>type of data: object
  data: [{"userid":"007", "role":"spy"}]
  user role: undefined
  </code></pre>
  
  <p>Also I tried another method of assignment:</p>
  
  <pre><code>currentUserRole = data['role'];
  </code></pre>
  
  <p>But currentUserRole remains <strong>undefined</strong>. How can I set a property of a JSON object to a variable?</p>