I have a class called Case which is like:
class Case {
String caseId;
Map <String, List<String[]>> listOfCases = new HashMap<String, ArrayList<String[]>>();
}
I created several of these cases and add them to a list. Eventually I want to print the list in JSON format in groovy like:
for (...){
// creating many of these cases in a loop and adding to caseList
caseList.add(myCase);
}
// Finally printing them
println new JsonBuilder( caseList ).toPrettyString()
Result looks like this, I chose one only:
{
"caseId": "Case_1",
"listOfCases": {
"server-config.xml": [
[
"Core",
"8"
]
],
"server-beans.xml": [
[
"plugin",
"mmap"
],
[
"maxIdle",
"16"
],
[
"minIdle",
"16"
],
[
"maxCon",
"16"
]
]
}
}
I want the listOfCases be replaced with Case_1 so each time I create a new Case with the number incremented, the name follows. Is there anyway to customize the jsonBuilder in groovy to do this ?