Last active
April 28, 2022 02:34
-
-
Save abdrehma/85e4b698f54944bf4eac9645e997bd8c to your computer and use it in GitHub Desktop.
Jenkins readJSON is very dodgy with null values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def filterJSON(map){ | |
map.each { key, value -> | |
if (value.toString() == "null"){ | |
map[key] = null | |
} else if (value instanceof List){ | |
map.eachWithIndex { item, index -> | |
if (item.toString() == "null"){ | |
map[index] = null | |
} | |
} | |
} else if (value instanceof Map){ | |
filterJSON(value) | |
} | |
} | |
} | |
def correctNullJSON = filterJSON(readJSON(file: "test.json")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://issues.jenkins.io/browse/JENKINS-53015