I am posting data to a server from the client side using an AJAX call. The data that is sent to the server is in the form of a JavaScript object, that is formed like this:
var dataObj = {
data: roleList,
count: count,
units: unitList
}
and is posted to the server via a JQuery Ajax call.
The problem is that when the data is received on the server, Grails is adding square brackets to the keys in the data as well as the values. For example, when I print out the "params" on the server, it looks something like this:
[data[]:[data1, data2, data3], count: 3, units[]:[unit1,unit2]]
Whereas it should look like:
[data:[data1,data2,data3]....]
The problem I have with these square brackets is that when I try to use a command object for validation of the data, then the data binding cannot take place as the variable names within the command object do not include the square brackets (and I of course can't create a variable name in Grails to include these brackets)
Does anyone know why these brackets are being added to the keys in the object (when it is the value that is an array and not the key itself) and what I can do to circumvent this problem?