Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Groovy jsonSlurper

satya_saraboju April 18, 2020

I am trying to run a curl command to get ServiceNow information and then get date. This script works fine when i run it on my mac but fails when i run it in JIRA console window

 

String jsonString = curl.execute().text

JsonSlurper jsonSlurper = new JsonSlurper()


Map convertedJSONMap = jsonSlurper.parseText(jsonString)

//If you have the nodes then fetch the first one only

if(convertedJSONMap."result"){

//println "u_status : " + convertedJSONMap."result"[0]."u_status"
//println "start_date : " + convertedJSONMap."result"[0]."start_date"
//println "end_date : " + convertedJSONMap."result"[0]."end_date"

def status = convertedJSONMap."result"[0]."u_status"
def s_date = convertedJSONMap."result"[0]."start_date"
def e_date = convertedJSONMap."result"[0]."end_date"

println "${status}"
println "${s_date}"
println "${e_date}"
currentDate = new Date()
println "now the time is ${currentDate}"
use( TimeCategory ) {
after30Mins = currentDate + 30.minutes
}

println after30Mins

1 answer

1 accepted

0 votes
Answer accepted
satya_saraboju April 18, 2020

this works, instead of using println need to use result

Suggest an answer

Log in or Sign up to answer