Forum Discussion
nmrao
Champion Level 3
It is trivial error.
You are expecting string "true" instead of boolean value. just remove the double quotes around true.
You can make out the data type of the json property value. If the value is enclosed between double quotes, then it is String type. Otherwise, it could be boolean, int, double, long etc.,
In your case
"success" : true
So:
def parsedResponse = new JsonSlurper().parseText(response.text)
assert true == parsedResponse.header.success
You are expecting string "true" instead of boolean value. just remove the double quotes around true.
You can make out the data type of the json property value. If the value is enclosed between double quotes, then it is String type. Otherwise, it could be boolean, int, double, long etc.,
In your case
"success" : true
So:
def parsedResponse = new JsonSlurper().parseText(response.text)
assert true == parsedResponse.header.success
richie
6 years agoCommunity Hero
nmrao yep - I already appreciated the datatypes and that boolean isn't a string so doesn't require the quote marks - I was just didn't notice cos I was overwhelmed with the rest of the groovy - trying to pick this stuff up and teaching myself coding from scratch on my weekends is slow going!
the problem in the end wasn't the type - it was the fact that my jsonslurper line
def parsedResponse = new JsonSlurper().parseText(response)
was wrong - I needed to add in the .text
def parsedResponse = new JsonSlurper().parseText(response.text)
All of a sudden - the star goes blue and I'm smiling! :)
NBorovykh nmrao thanks so much for all your help - you two rock! :)
richie
as