# Escape curly braces but inject a variable in it

**URL:** <https://community.postman.com/t/escape-curly-braces-but-inject-a-variable-in-it/18523>\
**Category:** Help Hub\
**Tags:** setenvironmentvariab\
**Created:** [December 16, 2020, 7:37pm UTC](https://community.postman.com/t/escape-curly-braces-but-inject-a-variable-in-it/18523 "2020-12-16T19:37:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kikketer](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Kikketer](https://community.postman.com/u/Kikketer)\
**Post date:** [December 16, 2020, 7:37pm UTC](https://community.postman.com/t/escape-curly-braces-but-inject-a-variable-in-it/18523/1 "2020-12-16T19:37:49Z")

</div>

I have a somewhat unique situation. The API I’m testing takes `{{` as part of the json body and uses it as a sort of macro.

I’d like to inject a variable into this macro, it looks like this without variables injected:

```
{
    "key": "Some text: {{DATE(2020-10-10T00:00:00.000Z),long}} some more text"
}

```

I’d like to be able to replace that date string with a Postman variable:

```
{
    "key": "Some text: {{DATE({{$TODAY}}),long}} some more text"
}

```

But it just sends the whole block of braces and doesn’t replace that date. Is there a way to escape the first curly braces or otherwise use a different technique to inject the variable?

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [December 17, 2020, 1:59am UTC](https://community.postman.com/t/escape-curly-braces-but-inject-a-variable-in-it/18523/2 "2020-12-17T01:59:06Z")

</div>

Hello @Kikketer,

Happy to have you as part of this Community 💐

So based on the snippets you have provided below, seems like the variable “TODAY” is a environment variable. If that’s the case the dollar is not required. We need to provide the $ for Dynamic variable like “$randomDateFuture”.

So if you have already defined the variable “TODAY” just access like below

```auto
{
    "key": "Some text: {{DATE({{TODAY}}),long}} some more text"
}

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/c/5/c54c610aae2fff4e78c0acf9f02b557f1fa43c79.png)

Else if you haven’t defined value for the variable, please try adding the below snippet to your **Pre-request script** section:

```auto
var moment = require('moment');

pm.environment.set('TODAY', moment().format(("YYYY-MM-DD")));

```

and access the variable “TODAY” as same.

I hope this helps 🙂
