How do I pass a composite JSON structure via AJAX call from JS and on the server side, read it as a \"very similar\" data structure in python?
I understand that json for
This is actually jQuery, not Django, being strange. Your test
variable does not contain JSON, but actual JS objects. jQuery, for reasons best known to itself, parses this into some very weird format before posting, hence the result you get. If you did this instead (note the quotes around the whole thing):
var test = '[{"id": 1},{"id": 2},{"id": 3}]';
you'd find you get very nearly the QueryDict you expect: the only thing you then need to do is to call json.loads(ret['json_data'])
.
Also for reasons that I can't understand. jQuery doesn't contain any functionality to convert your array of objects to JSON. You'll need to find a plugin or separate library for that.