I'm using python + Django to handle incoming web requests that can post a large amount of JSON attached as one of the POST data fields (e.g. var1=abc&json_var=lots_of_data&other_var=xxx). I'd like to process the JSON in a streaming fashion with my own streaming json parser which takes a file-like handle as its input argument. It appears from https://docs.djangoproject.com/en/1.11/ref/request-response/ that this is feasible, using HttpRequest.__iter__()
, but I can't find any examples of how to achieve this with my own code (i.e. not just importing a library like xml.etree.ElementTree).
Basically, I'd like to do the following:
POST request w/ big JSON => Django/python => create file-like handle to read POST => streaming url decoder => streaming JSON processor
I can use ijson for the streaming JSON processor. How do I fill in the two gaps for creating a file-like handle to the POST data and passing it to a streaming url decoder? Would prefer not to roll my own of either but I suppose if necessary I could.