Reading serialized data without json

22 views
Skip to first unread message

Joel Mathew

unread,
Nov 5, 2018, 6:17:04 AM11/5/18
to django...@googlegroups.com
Is it possible to read serialized data from javascript without encoding to json?

The data received by request.POST is:

<QueryDict: {'allergies[0][subst]': ['nsaid'], 'allergies[0][date]':
[''], 'allergies[1][subst]': ['alcohol'], 'allergies[1][date]': ['']}>

Sincerely yours,

Joel G Mathew

oon arfiandwi

unread,
Nov 5, 2018, 1:35:02 PM11/5/18
to django...@googlegroups.com

Hi,

have to try to convert the QueryDict to dictionary?
then try to get the keys as list.

>>> qdict
<QueryDict: {u'allergies[0][date]': [['']], u'allergies[1][subst]': [['alcohol']], u'allergies[0][subst]': [['nsaid']], u'allergies[1][date]': [['']]}>
>>> qdict.dict()
{u'allergies[0][date]': [''], u'allergies[1][date]': [''], u'allergies[0][subst]': ['nsaid'], u'allergies[1][subst]': ['alcohol']}
>>> qdict.dict().keys()
[u'allergies[0][date]', u'allergies[1][date]', u'allergies[0][subst]', u'allergies[1][subst]']
>>> 



still need some work to detect the list index and further keys, but now you can compare which way is easier to parse manually or serialize via json.

-- 
sincerely,
O


--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA%3Diw_9FW8QshYa9_K3rYMc%2BMF5vigZC3KdBFExvdH%2Bqves6ZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages