First to be clear up front let me say that I'm using Django1.7, Python 
2.7.8, and the requests (Requests: HTTP for Humans 
<http://docs.python-requests.org/en/latest/#requests-http-for-humans>) library 
version2.4.3 to build the application mentioned below. 

I have an application which needs to be able to process a single AJAX 
request as a series of related sub-requests sent to a remote API. Each 
sub-request response comes back in JSON format. The first of these 
sub-requests returns a list of students in a particular course, and the 
returned response data is a list containing student objects all in JSON 
format. A Django view code then strips outs the 'name' and 'id' of each 
student object in the list and builds it as an entry in another python list 
to be used later(I'm using "json.loads()" to get to successfully the 
original JSON data returned in each reasponse). Then once this list is 
built it is passed to another view which then submits a different request, 
for each student "id", in the newly built list, to the same API, to return 
all student information (related to a particular course-id which is also 
passed in this second request), for the current student. Then the returned 
course-student information, for this second request, is also returned in 
JSON format. 

Everything up to this point works perfectly, but it is at this point that I 
believe my process is going wrong, when I try to modify the JSON data 
returned, form the second series of requests. 

My modifications seem to work, on the server side(and I'm using 
json.dumps() to serialize my data into JSON format), and all of my data 
seems to be present when I print it in my command prompt window right 
before sending it back to the client, as part of an HttpResponse. Then when 
I try to access some of the data using javascript/jQuery once its 
been sent back to the client then some of the  "jQuery.parseJSON()" 
statements fail when I try to access the data I've formatted in the view, 
for my response. 

So my next question is how do I correctly modify the JSON response data 
(for each course student) returned from each request? Then once modified 
how do I correctly add it to a list, without breaking the JSON formatting, 
and causing it to not be well-formed, when I send it back to the client? 

This is the first time that I've attempted to do anything like this (modify 
and/or recombine) with JSON data, so I'm looking for an answer that my 
current level of Django/Python experience can't seem to provide, though I 
am continuing to search for answers. 

Any suggestions will be greatly appreciated.

Thanks for the help.

Henry

-- 
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/790b2c45-edc8-4528-9faa-4cecfc072626%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to