Basically at runtime I get an array like the following
var colors = ['red', 'green', 'blue'];
and I need to build a JSON string as below
{
"color" : {
"name" : "foo",
"properties" : {
...
}
},
"green" : {
"name" : "foo",
"properties" : {
...
}
},
"blue" : {
"name" : "foo",
"properties" : {
...
}
}
}
Is there any structure of String patterns that supports loops and control instructions for constructing a JSON string, as described above.
source
share