jsonPath and array

Hi there,
my REST-Service returns

{“index”:[{“provider_id”:“foo”,“etag”:“f77d14f2549485c4e087d3d7b1250cbd77b7da24”},{“provider_id”:“baz”,“etag”:“7de32bc8c614165c0c3a62dfda238cec0d7a5139”}]}

The expression $.index[*].provider_id should return (and the expression checker http://jsonpath.curiousconcept.com does)
[
“foo”,
“baz”
]

bat returns “baz” only

–Ulrich

Which version of Gatling are you using ?

Sorry,
Gatling2 Snapshot checked out April, 12th

“Mailing-list test case” should “work” in {
val json= parseJson( “”"{“index”:[{“provider_id”:“foo”,“etag”:“f77d14f2549485c4e087d3d7b1250cbd77b7da24”},{“provider_id”:“baz”,“etag”:“7de32bc8c614165c0c3a62dfda238cec0d7a5139”}]}""")
JsonPath.query( “$.index[*].provider_id”, json) should findElements(text(“foo”), text(“baz”))
}

With the last JsonPath engine, the following unit test is working fine.
Can you

“Mailing-list test case” should “work” in {
val json= parseJson( “”"{“index”:[{“provider_id”:“foo”,“etag”:“f77d14f2549485c4e087d3d7b1250cbd77b7da24”},{“provider_id”:“baz”,“etag”:“7de32bc8c614165c0c3a62dfda238cec0d7a5139”}]}""")
JsonPath.query( “$.index[*].provider_id”, json) should findElements(text(“foo”), text(“baz”))
}

With the last JsonPath engine, the following unit test is working fine.
Can you show me the associated Gatling script?
How do you come to the conclusion that the jsonPath() check isn’t working as expected ?

Regards
Nicolas

Hi Nicolas,

here comes the scenario definition:

val scn = scenario(“get service areas”)

.feed(ssv(“gabriel/devices.ssv”).circular)

.exec(

http(“get service_areas”)

.get("/service_areas")

.headers(Headers.default)

.header(“X-KWRN-Device-ID”,"${deviceId}")

.check(jsonPath("$.index[*].provider_id")

.saveAs(“providerIdList”))

.check(header(“Etag”).saveAs(“Etag”))

.check(status.saveAs(“status”), status.is(200)))

.exec(session=>{println(session)

session})

I simply printed the session, and providerIdList is in any case “foo”, the first element of the array

Would you mind trying again with the extra “.findAll”:

.check(jsonPath("$.index[*].provider_id").findAll.saveAs(“providerIdList”))

Thanks
Nicolas

Thanks