Skip to content

Instantly share code, notes, and snippets.

@nom3ad
Forked from mig82/parseJson.groovy
Created April 11, 2021 08:31
Show Gist options
  • Save nom3ad/58b3305410085b7bb4fd0f73c67bced4 to your computer and use it in GitHub Desktop.
Save nom3ad/58b3305410085b7bb4fd0f73c67bced4 to your computer and use it in GitHub Desktop.
How to parse json into a serializable HashMap in Jenkins Groovy
@NonCPS
def parseJson(txt){
def lazyMap = new groovy.json.JsonSlurper().parseText(txt)
def map = [:]
for ( prop in lazyMap ) {
map[prop.key] = prop.value
}
return map;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment