I have a dictionary that I get as a python dictionary in groovy which I then assign to a variable x :
def x = "{'JIRACHEF': 'PIBEP-2135', 'JIRADEPLOYER': 'PIBEP-2136', 'JIRASINGLEBUILD': 'PIBEP-2137'}"
I want to parse the above and get values for :
whats the most elegant groovy way of doing it ?
You can use the LAX slurper (in recent versions of Groovy):
import groovy.json.*
def x = "{'JIRACHEF': 'PIBEP-2135', 'JIRADEPLOYER': 'PIBEP-2136', 'JIRASINGLEBUILD': 'PIBEP-2137'}"
def parsed = new JsonSlurper().setType(JsonParserType.LAX).parseText(x)
println parsed.JIRACHEF
println parsed.JIRADEPLOYER
println parsed.JIRASINGLEBUILD
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.