Many times I have needed to declare a variable and that its name is the value of another variable dynamically.
Something like this: Example:
JSONObject fieldGruop = new JSONObject() //objeto json
//aqui itero por un array de objectos
Field.findAllByFieldGroupId(binding.groupId).each{ field ->
//aqui quiciera crearle al objeto "fieldGruop" propiedades con nombre igual al valor "name" de los field.
fieldGruop.${field.name} = cualquierValue //Mi duda es la Sintaxis
}
Thanks in advance.