# gatling build in jsonPath can't parse json. Online tester succeeded

**URL:** <https://community.gatling.io/t/gatling-build-in-jsonpath-cant-parse-json-online-tester-succeeded/1798>\
**Category:** Gatling (Open-Source)\
**Created:** [December 11, 2014, 9:19am UTC](https://community.gatling.io/t/gatling-build-in-jsonpath-cant-parse-json-online-tester-succeeded/1798 "2014-12-11T09:19:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregory\_Melekh](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@Gregory\_Melekh](https://community.gatling.io/u/Gregory_Melekh)\
**Post date:** [December 11, 2014, 9:19am UTC](https://community.gatling.io/t/gatling-build-in-jsonpath-cant-parse-json-online-tester-succeeded/1798/1 "2014-12-11T09:19:17Z")

</div>

Hi gatling experts.  
I try to parse JSON (attached below) with code

.  
.  
.  
.check(jsonPath("$.[0].unit").is(“flow.flow-server.sandbox.${username}project.${username}.service”).saveAs(“unit”)) .check(jsonPath("$.[0].active").is(“active”).saveAs(“active”)) .check(jsonPath("$.[0].sub").is(“running”).saveAs(“sub”))

but it doesn’t work.  
Online tester succeeded to parse this JSON with same matcher as mine. ([http://jsonpath.curiousconcept.com/](http://jsonpath.curiousconcept.com/) )  
I saw that gatling uses jsonPath 0.6.1 ,and online one is 0.8.X (by Stephan Goessner).

May somebody please help me to parse this JSON.

[{ “unit”:“flow.flow-server.aaa.gatlinguser202project.gatlinguser202.service”, “machine”: “f374e9a176b341d4a8ee8db3cdfb2958/10.11.12.124”, “active”: “active”, “sub”: “running”, “space”: “aaa.gatlinguser202project.gatlinguser202”, “@timestamp”: 1418285656070 }, { “unit”: “XXXXXXXflow.flow-server.aaa.gatlinguser202project.gatlinguser202.service”, “machine”: “f374e9a176b341d4a8ee8db3cdfb2958/10.11.12.124”, “active”: “active”, “sub”: “running”, “space”: “aaa.gatlinguser202project.gatlinguser202”, “@timestamp”: 1418285656070 }]

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [December 11, 2014, 9:52am UTC](https://community.gatling.io/t/gatling-build-in-jsonpath-cant-parse-json-online-tester-succeeded/1798/2 "2014-12-11T09:52:13Z")

</div>

> Online tester succeeded to parse this JSON with same matcher as mine. (  
> [http://jsonpath.curiousconcept.com/](http://jsonpath.curiousconcept.com/) )

Really? Because this online tester complains that your expressions are not  
valid.  
And indeed, the proper syntax is $[0].unit not $.[0].unit

---

<div class="post-metadata">

**Author:** ![Gregory\_Melekh](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@Gregory\_Melekh](https://community.gatling.io/u/Gregory_Melekh)\
**Post date:** [December 11, 2014, 10:13am UTC](https://community.gatling.io/t/gatling-build-in-jsonpath-cant-parse-json-online-tester-succeeded/1798/3 "2014-12-11T10:13:01Z")

</div>

Thank you Stephane. It Works fine.

P.S.  
Online jsonPath works also with ($.[0].unit) …just checked.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [December 11, 2014, 10:17am UTC](https://community.gatling.io/t/gatling-build-in-jsonpath-cant-parse-json-online-tester-succeeded/1798/4 "2014-12-11T10:17:44Z")

</div>

Ah, OK, it works with Stefan Goessner’s implementation, but not with the one from Flow Communication (default).  
If even the spec’s original author is not capable of respecting his own spec… Javascript is such a crap…

---

<div class="post-metadata">

**Author:** ![Gregory\_Melekh](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@Gregory\_Melekh](https://community.gatling.io/u/Gregory_Melekh)\
**Post date:** [December 11, 2014, 11:27am UTC](https://community.gatling.io/t/gatling-build-in-jsonpath-cant-parse-json-online-tester-succeeded/1798/5 "2014-12-11T11:27:07Z")

</div>

Stephane Is exists any way to locate highlighted object in the JSON without running over JSONArray ? I can’t be sure that desired object always located in place [0] of array ?  
Thanks for Advance.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [December 11, 2014, 11:30am UTC](https://community.gatling.io/t/gatling-build-in-jsonpath-cant-parse-json-online-tester-succeeded/1798/6 "2014-12-11T11:30:34Z")

</div>

$…unit

---

<div class="post-metadata">

**Author:** ![Gregory\_Melekh](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@Gregory\_Melekh](https://community.gatling.io/u/Gregory_Melekh)\
**Post date:** [December 11, 2014, 11:47am UTC](https://community.gatling.io/t/gatling-build-in-jsonpath-cant-parse-json-online-tester-succeeded/1798/7 "2014-12-11T11:47:54Z")

</div>

Maybe something else? it doesn’t works.  
I need to parse values of “active” and “sub” where unit =flow.flow-server.sandbox.gatlinguser202project.gatlinguser202.service.  
JSONArray can contains 10 objects with different “unit” .

Thanks for advance.

This is log…  
**13:39:50.074 [WARN] i.g.h.a.AsyncHandlerActor - Request ‘Check Connecting Mode is ready’ failed: jsonPath(…unit).find(0).is(flow.flow-server.sandbox.gatlinguser202project.gatlinguser202.service) failed, could not extract: could not extract : `$' expected but `.’ found**
