Hi,
I'm using a ScriptRunner post function that get the value of a CustomField(text read only) and parse this String in a Json and after that read the content of the Json and do something(it Works).
The problem is when in the customfield is passed a String that is not in the correct format(Json), for example if there isn't the first { or the last } of the Json, in this case the post function Failed and i Get this error:
2021-01-20 09:10:42.847 ERROR - expecting a ',' or a ']', but got
the current character of ':' with an int value of 58 on array index of 1
The current character read is ':' with an int value of 58
expecting a ',' or a ']', but got
the current character of ':' with an int value of 58 on array index of 1
line number 1
index number 5
["id":"DefectD1","tipologia":"Consegna","descrizione":"defect"} , {"id":"DefectD1","tipologia":"Installazione","descrizione":"defect"}]
.....^
2021-01-20 09:10:42.906 ERROR - Class: com.adaptavist.sr.cloud.workflow.RunScript, Config: [className:com.adaptavist.sr.cloud.workflow.RunScript, uuid:4b8da94e-8b0e-4dcf-8ade-2e81f299b89f, enabled:true, executionUser:ADD_ON, condition:((Map) issue.fields.issuetype)?.name == 'Drop', description:Script, additionalCode:import groovy.json.*
The part of the Code that Parse the String in the Json is this:
String jsonStr = listaAttributiD
def res = (new JsonSlurper().parseText(jsonStr)) as Map //HERE IS WHERE THE ERROR LOADS
There is a way to catch this error and prevent the failed of the Post Function?
Thanks