So I basically have a modal to add an object, that I want to serialize to JSON Object. To serialize each input will have a name and value of course.
The thing is one of those inputs have a value which is an array (list of ids). This input is actually hidden and I have set it my self.
Following are the steps I followed
Set the hidden input values
$('input[name="students"]').val(JSON.stringify(idsArray));
Serialize the form into object
action_object = $('.actionForm').serializeObject();
Source for SerialzeObject function Convert form data to JavaScript object with jQuery
Convert to JSON object
action_JSON = JSON.stringify(action_object);
Result is as following
{"Title":"","students":"[\"2015022\",\"2015027\",\"2015032\"]","ActionType":"3","Description":"yjtkt","Date":"2015-11-17"}
Now the object seems ok.
However check for the students array. Is that normal and if not how that can be fixed ?