Hi All,
I need to implement contains for the attributes transformed as Map
I have transformed a json into Map. I am able to use it inside json file as #{payload.status} for which I get the value and also works on switch case
doSwitch(“#{payload.status}”)
But I am unable to implement for the below:
eg: 1
doIf(session => session(“payload.status”).as[String].contains(“ABC”)) { }
Are you sure that payload.status contains your map? Perhaps its payload. The doSwitch has the expression payload.status and that means get me the value of status key from the Map payload stored in the session. Perhaps you want to do a contains on a different value thats addressed by a different key
You are missing session => and I think my solution might not work and you might have to use a very verbose way of doIf like. It would be easier for you to extract this value from the JSON response using JmesPath or JsonPath and transform and store in the session
doIf( session => {
val payload = session("payload").as[Map[String,Any]]
val status = payload("status").asInstanceOf[Map[String,Any]]
status("update").toString.contains("ABC"))
})
PS - I’m typing this on my cellphone so pardon the syntactical errors