# What parse and/or setEnvironmentVariable statement(s) must i use to get C2 from { "C1:C2"}?

**URL:** <https://community.postman.com/t/what-parse-and-or-setenvironmentvariable-statement-s-must-i-use-to-get-c2-from-c1-c2/234>\
**Category:** Help Hub\
**Tags:** parse, string, setenvironmentvariab\
**Created:** [November 14, 2017, 10:55pm UTC](https://community.postman.com/t/what-parse-and-or-setenvironmentvariable-statement-s-must-i-use-to-get-c2-from-c1-c2/234 "2017-11-14T22:55:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TienLeCarlsbad](https://avatars.discourse-cdn.com/v4/letter/t/4af34b/32.png) [@TienLeCarlsbad](https://community.postman.com/u/TienLeCarlsbad)\
**Post date:** [November 14, 2017, 10:55pm UTC](https://community.postman.com/t/what-parse-and-or-setenvironmentvariable-statement-s-must-i-use-to-get-c2-from-c1-c2/234/1 "2017-11-14T22:55:02Z")

</div>

Hi,

May I get some help with using the proper parse and/or setEnvironmentVariable so that I can write a needed value to my environment variable?

I’m getting a response of

```
[
  {
    "A": "B",
    "C": "D",
    "E": [
           "F1:F2",
           "G1:G2",
           "H1:H2"
    ],
    "I1": "I2",
    "J1": "J2"
  }
]

```

I’m thinking that my postman.setEnvironmentVariable(“F”, );

I’ve tried  
var jsonData = JSON.parse(E[0].F1);  
postman.setEnvironmentVariable(“serviceTypeId”, jsonData[1]);  
but it’s not working.

I know that the var statement isn’t quite correct. What should it be? I probably don’t have the setEnvironmentVariable statement correct either.

help!

thanks,  
Tien

---

<div class="post-metadata">

**Author:** ![ankit.jaggi](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/ankit.jaggi/32/88_2.png) [@ankit.jaggi](https://community.postman.com/u/ankit.jaggi)\
**Post date:** [November 15, 2017, 2:53pm UTC](https://community.postman.com/t/what-parse-and-or-setenvironmentvariable-statement-s-must-i-use-to-get-c2-from-c1-c2/234/2 "2017-11-15T14:53:57Z")

</div>

The response body is available as the `responseBody` variable in the test scripts. In order to get the specific value, you can do something like this.

```auto
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("serviceTypeId", jsonData[0].E[0]);

```

This should set the environment variable with the value `F1:F2`.

I hope this is what you are looking for.

---

<div class="post-metadata">

**Author:** ![TienLeCarlsbad](https://avatars.discourse-cdn.com/v4/letter/t/4af34b/32.png) [@TienLeCarlsbad](https://community.postman.com/u/TienLeCarlsbad)\
**Post date:** [November 15, 2017, 8:37pm UTC](https://community.postman.com/t/what-parse-and-or-setenvironmentvariable-statement-s-must-i-use-to-get-c2-from-c1-c2/234/3 "2017-11-15T20:37:35Z")

</div>

you rock, sir! Thank YOU.
