henil_shah
6 years agoContributor
Create json in Groovy
Need to create Json like this
"data":
{
"data1":"data1",
"data2":"data2"
}
}
I'm able to create the below one but not the above one. I'm using def json = new JsonOutput().toJson(obj...
- 6 years ago
Would you please check this script
You may test it online in the above link.
import static groovy.json.JsonOutput.toJson import static groovy.json.JsonOutput.prettyPrint def data = [data1: "data1", data2: "data2"] def jsonString = prettyPrint(toJson(data: data).toString()) log.info jsonString