# Correlation using JAVA DSL

**URL:** <https://community.gatling.io/t/correlation-using-java-dsl/6593>\
**Category:** Gatling (Open-Source)\
**Created:** [March 17, 2022, 10:06pm UTC](https://community.gatling.io/t/correlation-using-java-dsl/6593 "2022-03-17T22:06:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AshishChadda](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@AshishChadda](https://community.gatling.io/u/AshishChadda)\
**Post date:** [March 17, 2022, 10:06pm UTC](https://community.gatling.io/t/correlation-using-java-dsl/6593/1 "2022-03-17T22:06:20Z")

</div>

`.check(jmesPath("$.data.trackCode").saveAs("trackCode"))`

The above code is throwing an error stating

`jmesPath($.data.trackCode).find.transform.exists extraction crashed: i.b.j.p.ParseException: Unable to compile expression "$.data.trackCode": syntax error token recognition error at: '$' at position 0, syntax error extraneous input '.' expecting {'!', '(', '*', '[', '{', '[?', '@', '`', RAW\_STRING, JSON\_CONSTANT, NAME, STRING} at position 1`

I like to extract the trackCode from below response and save it to variable say “trackCode”:  
Response Body  
`{"data":{"trackCode":"XYZ","isNewUser":false}}`

Expected Result: trackCode=XYZ

Also, could someone please share the Gatling cheat sheet URL or user guide with a few correlation examples?  
Thanks

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [March 18, 2022, 8:25am UTC](https://community.gatling.io/t/correlation-using-java-dsl/6593/2 "2022-03-18T08:25:15Z")

</div>

Hello,

`jmesPath` is not `jsonPath`

Try with `jmesPath("data.trackCode")` instead.  
Documentation:

- [Gatling - Checks - jmesPath](https://gatling.io/docs/gatling/reference/current/core/check/#jmespath)
- [JMESPath documentation](https://jmespath.org/)

Cheers,

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [March 18, 2022, 8:37am UTC](https://community.gatling.io/t/correlation-using-java-dsl/6593/3 "2022-03-18T08:37:55Z")

</div>

Also, here’s the reference website for JMESPath where you can learn the proper syntax: [https://jmespath.org/](https://jmespath.org/)

---

<div class="post-metadata">

**Author:** ![AshishChadda](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@AshishChadda](https://community.gatling.io/u/AshishChadda)\
**Post date:** [March 18, 2022, 6:24pm UTC](https://community.gatling.io/t/correlation-using-java-dsl/6593/4 "2022-03-18T18:24:38Z")

</div>

Thanks @sbrevet and @slandelle . I will explore other ways for extracting like regex, json etc
