Migrating from 2.0 to 2.2 - One last bit of help needed

I am almost done migrating my code base to 2.2. Most of the changes have been relatively simple to figure out. But there is one left that I need some help with.

I have a bunch of implicits that I created which allows me to extend the DSL with session management syntactic sugar. There is one method that does not compile under 2.2:

`

import io.gatling.core.json.Boon
import io.gatling.core.check.extractor.jsonpath._

object SessionManagement {

implicit class SessionManagementExtensions[T <: StructureBuilder[T]]( val c : T ) {

private def extractAll( path: String, json: String ) =
JsonPathExtractor.extractAll[String]( Boon.parse( json ), path ) match {
case Success(x) => x.toVector
case Failure(msg) => throw new Error( msg )
}

private def setVarExtract( dest: SessionVariable, path: String, src: SessionVariable) =
c.exec( session => session.set( dest, extractAll( path, session(src).as[String] ).head ) )

private def setVarExtractAll( dest: SessionVariable, path: String, src: SessionVariable ) =
c.exec( session => session.set( dest, extractAll( path, session(src).as[String] ) ) )

`

When compiled, it reports as follows:

`

18:27:00.666 [ERROR] i.g.c.ZincCompiler$ - /src/poc/rtde/src/scala/com/cigna/common/SessionManagement.scala:57: not found: value JsonPathExtractor
18:27:00.670 [ERROR] i.g.c.ZincCompiler$ - JsonPathExtractor.extractAll[String]( Boon.parse( json ), path ) match {
18:27:00.670 [ERROR] i.g.c.ZincCompiler$ - ^
18:27:00.673 [ERROR] i.g.c.ZincCompiler$ - /src/poc/rtde/src/scala/com/cigna/common/SessionManagement.scala:57: not found: value Boon
18:27:00.673 [ERROR] i.g.c.ZincCompiler$ - JsonPathExtractor.extractAll[String]( Boon.parse( json ), path ) match {
18:27:00.674 [ERROR] i.g.c.ZincCompiler$ - ^
18:27:00.684 [ERROR] i.g.c.ZincCompiler$ - /src/poc/rtde/src/scala/com/cigna/common/SessionManagement.scala:58: value toVector is not a member of Any
18:27:00.685 [ERROR] i.g.c.ZincCompiler$ - case Success(x) => x.toVector
18:27:00.685 [ERROR] i.g.c.ZincCompiler$ - ^

`

You had said here that I “should probably be creating a MultipleJsonPathExtractor instance” but when I search for that, I don’t find anything.

May I ask, what are the changes I need to make in order to get this code to work the way it did in 2.0?

Is this the file I should look to for inspiration on how to make this work?

https://github.com/gatling/gatling/blob/master/gatling-core/src/test/scala/io/gatling/core/check/extractor/jsonpath/JsonPathExtractorSpec.scala

Beware: 2.2 is under development. Those milestones you can find on central were released for our customers, are not documented, and internals (like what you are using) as still changing.

Yes, you probably want to have a look at how we do things in JsonPathExtractorSpec.

But it might also be safer to not depend on Gatling internals.

Yes, it would be safer, and preferable. What is the SAFE way to take a JSON string, stored in session, and parse it and extract a jsonPath from it?

What is the SAFE way to take a JSON string, stored in session,

You know how to do that

and parse it

Raw Jackson or Boon. Plain old Java.

and extract a jsonPath from it?