Assign a JSON value (337 characters) to a Jenkins String variable. The variable become a null object

I have curl respond and need to extract a 337 characters long token. I parsed the JSON respond with the JSONSlurper. But as soon as I assign the JSON value to the Jenkins String variable the variable becomes a null object, any bugs or string length limitation?

Here is my test script

def parser = new groovy.json.JsonSlurper()
def token_respond=parser.parseText(respond)
def token=‘ABCD test’
println token
token=token_respond.I’d
println token

The first println print out “ABCD test’ correctly
The second println get error
“Cannot get property ‘token’ on null object.

Please help

Have you tried dumping the “respond” variable to see if it has the correct data? I would recommend using readJson instead of JsonSlurper. You can run into security issues with JsonSlurper.

See Pipeline Utility Steps for info on readJson.