Solved: Thanks to below answer from S.Richmond. I needed to unset all stored maps of the groovy.json.internal.LazyMap
type whi
EDIT: As pointed out by @Sunvic in the comments, the below solution does not work as-is for JSON Arrays.
I dealt with this by using JsonSlurper
and then creating a new HashMap
from the lazy results. HashMap
is Serializable
.
I believe that this required whitelisting of both the new HashMap(Map)
and the JsonSlurper
.
@NonCPS
def parseJsonText(String jsonText) {
final slurper = new JsonSlurper()
return new HashMap<>(slurper.parseText(jsonText))
}
Overall, I would recommend just using the Pipeline Utility Steps plugin, as it has a readJSON step that can support either files in the workspace or text.