Hi Team,
When I am trying to convert the a string value to JSON usind JSON slurper I am getting null. Not sure why.
JiraNewTicketJSON = {"fields":{"project":{"key":"TESTCM"},"issuetype":{"name":"Change Request"},"summary":"Testing","description":"Testing description",}}}}
finalBodyJson = JsonOutput.toJson(JiraNewTicketJSON)
jsonContent = new JsonSlurper().parseText(finalBodyJson)
finalJsonContent = groovy.json.JsonOutput.toJson(jsonContent.content)
I am getting
finalBodyJson as {"fields":{"project":{"key":"TESTCM"},"issuetype":{"name":"Change Request"},"summary":"Testing","description":"Testing description",}}}}
but jsonContent is null
Regards,
Sunil
You may want to modify your code slightly, as shown below:-
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
def JiraNewTicketJSON = "{'fields':{'project':{'key':'TESTCM'},'issuetype':{'name':'Change Request'},'summary':'Testing','description':'Testing description'}}}}"
def finalBodyJson = JsonOutput.toJson(JiraNewTicketJSON)
log.warn "====>> 1 ${finalBodyJson}"
def jsonContent = new JsonSlurper().parseText(finalBodyJson)
log.warn "====>> 2 ${jsonContent}"
def finalJsonContent = JsonOutput.toJson(jsonContent)
log.warn "====>> 3 ${finalJsonContent}"
Below is a print screen of this code and the test output:-
I hope this helps to solve your question. :)
Thank you and Kind Regards,
Ram
@Ram Kumar Aravindakshan _Adaptavist_ ,
I tried the method but it still gives null value.
Regards,
Sunil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am getting the log values but the ticket is not getting created and if I try to get the status code it says we cannot post on Null value
Regards,
Sunil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please share your full code? In the code that you have provided in your description, it is missing certain lines.
Thank you and Kind Regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.