title: Postman -- Unable to use environment variable when extracting from JSON response
body: <p>I have a suite of postman collections.  The server supports two type of user roles, partner and customer.  The restful server URLs include the role name (e.g. <code>http://server.com/customer/account</code> and <code>http://server.com/partner/account</code></p>
  
  <p>The JSON data also differs by role.</p>
  
  <pre><code>"account" : {
    "customer" : {
      "name" : "Fred"
    }
  }
  
  "account" : {
    "partner" : {
      "name" : "Fred"
    }
  }
  </code></pre>
  
  <p>I am trying to extract the name, but postman doesn't like the embedded environment variable specifying the role to use to extract the response.  The environment variable works fine for creating the request.</p>
  
  <pre><code>var jsonData = JSON.parse(responseBody);
  postman.setEnvironmentVariable("user_name", jsonData.account.{{role}}.name);
  </code></pre>
  
  <p>Postman reports a syntax error (<code>Unexpected '{'</code> ) so I'm not hopeful, but is there a way to do this?</p>
  
  <p>--- UPDATE ---
  I've found a workaround that is OK, but not as elegant.</p>
  
  <pre><code>if (environment["role"] == 'partner') {
    postman.setEnvironmentVariable("user_name", jsonData.account.partner.name);
  } else {
    postman.setEnvironmentVariable("user_name", jsonData.account.customer.name);
  }
  </code></pre>