jsonpath differences between v1.5.6 and v2.0.0

Hi,

having a spot of bother getting this extractor to work

$…[?(@.type==‘HAHVACTemperatureSensor’)].id

for this json response body:
[{“id”:“AD-01-01-01-01-01-01-01”,“name”:“Lamp 1”,“type”:“Lamp”,“protocol”:[],“isZwave”:false,“isGeneric”:false},{“id”:“00-1E-5E-09-02-03-86-AD”,“name”:“Your Receiver”,“type”:“HAHVACThermostatSLR2”,“protocol”:[“zigbee”],“isZwave”:false,“isGeneric”:false,“minTemperatureSetting”:5,“maxTemperatureSetting”:32,“maxNumSetpoints”:6},{“id”:“00-1E-5E-09-02-00-54-CC”,“name”:“Your Thermostat”,“type”:“HAHVACTemperatureSensor”,“protocol”:[“zigbee”],“isZwave”:false,“isGeneric”:false}]

The extractor worked fine when run under v1.5.6 but fails under v2.0.0 with:

failed: jsonPath($…[?(@.type==‘HAHVACTemperatureSensor’)].id).find(0).exists failed, could not extract: could not extract : string matching regex [$_\p{L}][$_\-\d\p{L}]*' expected but [’ found

can anyone help me get this right please,

thanks

Chris

In Gatling 2, we ditched slow and buggy Jayway’s JsonPath implementation and built our own.

It seems to me that your expression isn’t valid (missing wildcard for the field name) and shouldn’t have worked in the first place.

$…*[?(@.type==‘HAHVACTemperatureSensor’)].id

Thanks Stephane,

unfortunately that doesn’t work either.

jsonPath($…*[?(@.type==‘HAHVACTemperatureSensor’)].id).find(0).exists, found nothing

The original worked fine with the earlier implementation and also at this site: http://ashphy.com/JSONPathOnlineEvaluator/
but, I cannot get it to work at all (it just returns an error) at this site: http://jsonpath.curiousconcept.com/ nor with gatling 2.0.0

Is there a simple way (without firing up a complete gatling scenario) to test these expressions?

regards

Chris

Actually, you want some element in the root array, so you shouldn’t be using recursive descent.
$[?(@.type==‘HAHVACTemperatureSensor’)].id

BTW, this exact use case was covered in our tests: https://github.com/gatling/gatling/blob/master/gatling-core/src/test/scala/io/gatling/core/check/extractor/jsonpath/JsonPathExtractorSpec.scala#L85

Hi Stephane,

Thats it! it now works. Thank you,

Chris