On Thu, Feb 5, 2015 at 2:10 PM, Henry Versemann <fencer1...@gmail.com> wrote: > I have a django view (django v. 1.7 ; python v. 2.7.8) which currently and > successfully sends a request to an api, and receives a good response back. > I'm sending and receiving using the 'requests' library (v. 2.4.3). Now in > addition to sending the raw response data back in an HttpResponse I would > also like to strip out some of the data and create a summary report of it, > to also send back in my HttpResponse. > > I can see the good response data from the request in my command prompt > window, and it contains a list of items inside of the object to which I've > assigned the response data. So my question is how do I get at the list of > items that has been returned back to me as well as all of the data > (key/value pairs) contained in each list item? > > I'm sure there must be some kind of conversion process that I have to run > the raw response data through. I just haven't out what it is yet. > > I've never tried to do this before, from within a django view. If I were > trying to do this on the client side I would use something like this: > > mydata = jQuery.parseJSON(data); > > to make the data accessible, but never having done anything like this before > on the server side I haven't found anything yet that's been useful or has > worked. > > I would appreciate any help anyone can offer, while I continue to search for > an answer.
See: https://docs.python.org/3.3/library/json.html e.g.: import json jsonIn = json.loads(request.POST['json_content']) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACwCsY4cV8ion7%3DY6e_nmCvzdTF7VCejA%2BCDRvx_JUZoJ%3D_HMw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.