I am sending the array of dicts from javascript to python via a POST request that looks this way:
mydata.push({
department_id: department_id,
cardgroup_id: cardgroup,
doorgroup_id: doorgroup
});
$.post("data/save-office/"+office, {'data': JSON.stringify(mydata)}, function (data) {
console.log(data);
});
When extracting the payload in python
:
departments = request.form.getlist('data')
The output is:
departments = ['[{"department_id":"1","cardgroup_id":"2","doorgroup_id":"2550"},
{"department_id":"2","cardgroup_id":"2","doorgroup_id":"2550"},
{"department_id":"3","cardgroup_id":"2","doorgroup_id":"2550"},
{"department_id":"4","cardgroup_id":"2","doorgroup_id":"2550"}]']
This displayed output is an array of one index and the inside is treated as a string rather than a dictionary.
How can I filter it or send it from javascript so that it can be decoded as an array of dicts not an array of strings?