Presentation Buddies
Presentation Buddies

Reputation: 11

How to parse a javascript list containing dictionary in python django

I have a webhook.

data0=[{"senderId":"smsdia","requestId":"******383233353233","report":[{"date":"2017-12-02 17:00:41","number":"12345","status":"1","desc":"DELIVERED"}],"userId":"119385","campaignName":"viaSOCKET"}]

I receive the above data in a POST request to my server.

Content-Type: application/x-www-form-urlencoded

How do I parse it?

I know that if it is a list: data1=['sree','kanth'] I can parse it with request.POST.getlist('data1[]')

But I don't know how to parse when it is a list containing dict.

edit1

Moreover, I get len(data1) is 2. But len(data0) is 0.

edit2 using request.lib: https://requestb.in/13df2891?inspect

Upvotes: 0

Views: 49

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599490

This appears to be JSON sent inside a form field. You can use the json library to parse it:

data = json.loads(request.POST['data'])

Upvotes: 2

Related Questions