Json String转换为Json Object
Json String转换为Json Object
Pipeline中写法如下:
ec2 = '{"first_name":"John","full_name":"John Doe","last_name":"Doe"}' println ec2.getClass() //Return: class java.lang.String // Convert String to Map def map = new groovy.json.JsonSlurper().parseText(ec2) println map //Return: {first_name=John, full_name=John Doe, last_name=Doe} println map.getClass() //Return: class groovy.json.internal.LazyMap println map['first_name'] //Return: John
参考:https://www.jianshu.com/p/9475c6c92cd2