REST - Script Assertion fails due to square brackets in Json response.
I'm trying to do a script assertion for my project, I need to check the FirstHolder name matches with the expected name. I'm using the below code.
import groovy.json.JsonSlurper
def response = messageExchange.response.responseContent
def textresponse = new JsonSlurper().parseText(response)
Actual = textresponse.BankAccount.FirstHolder
assert "Myname" == Actual"
The problem I'm facing here is both the names Myname and the name store inside Actual are same, but the assertion is getting failed.
First, I found is the content stored inside the Actual is coming as [MyName] while doing log.info but my expected is MyName.
Second, I tried like this assert "[MyName]" == Actual, but its also failed.
Third,I tried saving Myname in the testcase custom properties and assesing it using context but again failed.
I'm stuck here, needed help asap. I think the response coming with brackets is the problem, but how to extract it without brackets?
its its a bracket its an array so maybe try [0]
Just throwing an idea