json - How do I get the actual value from this in Scala : Right(Vector("abc")) -
i'm using gatling test websocket based service , in order parse json response use following:
val initiator = jsonpath.query("$.header.initiator", json).right.map(_.tovector)
printing initiator tells me :
right(vector(guest3075085133639688955@example.com))
now beginner scala question:
how actual string value "guest3075085133639688955@example.com" ?
i've understood right container, contains vector 1 value (the value want), how ?! :)
i've tried this, prints same thing (right(vect....):
initiator.foreach{println}
cheers, niklas
initiator.right.get
either unsafe. because throws java.util.nosuchelementexception
if left value.
by pattern matching:
initiator match { // when right value, vector single element case right(vector(s)) => println(s) // when right value, vector empty or 2 or more elements. case right(v) => ??? // when left value case left(l) => ??? }
Comments
Post a Comment