I have this swf (flash) file that provides the json that needs to be sent to the server.
I wrote a very simple jQuery:
function submitForm(swf_json) {
$('#swfjson').val(swf_json); #swfjson is an input of type hidden
$('#titleForm').submit();
}
and the swf will call the submitForm above and I receive the request.POST in django as usual.
But, django is interpreting the swf_json as a string "Object object"
>>>type(request.POST['swfjson'])
<type 'unicode'>
Of course I can pass the json as a string to the view function. Doesn’t seem good to me. Any other way of passing the json object to the django view?
Of course django sees the string “Object object”. That’s excatly what jQuery writes into the input field. And what subsequently gets submitted. (Demo)
The
swf_jsonparameter is an object to javascript. If you want to submit it as string I suggest slightly modifying the swf so that it passes a string to your function instead of an json object. Assuming you construct your json via string concatenation just add extra quotation marks at the end and beginning before callingsubmitFormInstead of
try this
If I remember correctly https://github.com/douglascrockford/JSON-js/blob/master/json2.js allows conversion between json and strings