Search code examples
scalagatling

In Gatling/Scala how do I convert a jsonPath into an array?


The following check produces an error claiming

No member of type class JsonFilter found for type Seq[String]

...
.check(
jsonPath("$..foo").ofType[Seq[String]]
   .transform((a) => {println(a);a})
   .saveAs("bar")
)

Given the following json, I'd expect the out put to look like: List(f1, f2, f3)

{
"one": {"foo": "f1"},
"two": {"foo": "f2"},
"three": {"foo": "f3"},
}

Solution

  • findAll is what I was searching for.

    .check(
    jsonPath("$..foo").findAll
       .transform((a) => {println(a);a})
       .saveAs("bar")
    )
    

    Sources