JsonPath check fails

Hello,

I try to retrieve a value from a JSON server response, but the JSonPath check returns a wrong value.
The server response looks like the following JSON content :

{
“name”:“The system 21450001-000001”,
“applications”:[{“uid”:“cdb6c07c2e544f4e83846185364efce0”,“name”:“perf-msci-app-6668fc842f5a46418c45caf3773da9f1”,“revision”:“V1.0”,}],
“gateway”:{“imei”:“21450001-000001”,“macAddress”:null,“serialNumber”:“21450001-000001”,“type”:null,“uid”:“c0ca8e6a6ffc4fc2860bb77898539e4b”,“state”:“INVENTORY”},
“uid”:“553e68f54455486b87d846e462118a47”,
“state”:“INVENTORY”,
“activityState”:“ACTIVATED”
}

I want to retrieve the field " /uid “, but the “.check(jsonPath(”/uid”)" returns the value of the first “uid” field found.
Indeed, in my case, it returns the value of the field “/applications/uid”, so it’s wrong.

Do I forgot something, or it is a bug ?

Best Regards,
Sébastien.

Hi,

I did this test : https://gist.github.com/3907686
I think it’s unfortunately a bug …

Nicolas

Hi,

Thanks for your test.
I hope it will be fixed in the next version.

Sébastien.

@Sébastien I was able to fix it (didn’t push yet), but I have a problem with your sample.

The application element has a trailing comma that’s actually illegal, even if some browsers do support it (yet another way to encourage internet mess…).
Are you sure you were able to parse it with Gatling (even if the result was wrong) or did you actually edit it to make it shorter? Because Jackson (the underlying JSON engine) isn’t supposed to support this.

“applications”:[{“uid”:“cdb6c07c2e544f4e83846185364efce0”,“name”:“perf-msci-app-6668fc842f5a46418c45caf3773da9f1”,“revision”:“V1.0”, ← illegal comma here }],

Cheers,

Steph

2012/10/18 Sebastien <sangoken@gmail.com>

Hello Stéphane,

It’s just a mistake when I copied the JSON example in this post.
Of course, it’s not a valid JSON content.

In my case, I currently changed some things in order to have only one “uid” field into the serveur response, and work arround this bug.

Thanks,
Sébastien.

If you can find some time, could you try the latest snapshot here, please?

http://repository-gatling.forge.cloudbees.com/snapshot/com/excilys/ebi/gatling/highcharts/gatling-charts-highcharts/1.4.0-SNAPSHOT/

Cheers,

Stéphane

2012/10/19 Sebastien <sangoken@gmail.com>

I tried my simulations with this 1.4.0 SNAPSHOT, and it works fine :slight_smile:
Thanks for the fix.

Cheers,
Sébastien.

Very cool!

I will release 1.3.4 on monday morning.

Thanks again for your feedback!
Cheers,

Stéphane

2012/10/19 Sebastien <sangoken@gmail.com>