During runtime, I receive an array similar to the example below:
var colors = ['red', 'green', 'blue'];
I then need to create a JSON String that looks like this:
{
"color" : {
"name" : "foo",
"properties" : {
...
}
},
"green" : {
"name" : "foo",
"properties" : {
...
}
},
"blue" : {
"name" : "foo",
"properties" : {
...
}
}
}
Are there any String templating frameworks available that support loops and control statements for constructing a JSON String in the specified format?