[Django]-Django/python is converting my post data from JavaScript

7👍

How are you encoding your JSON string? The single quotes need to be double quotes, per the spec:

In [40]: s1 = "{'mid':1,'sid':27,'name':'aa','desc':'Enter info' }"

In [41]: simplejson.loads(s1)
JSONDecodeError: Expecting property name: line 1 column 1 (char 1)

In [42]: s2 = '{"mid":1,"sid":27,"name":"aa","desc":"Enter info" }'

In [43]: simplejson.loads(s2)
Out[43]: {'desc': 'Enter info', 'mid': 1, 'name': 'aa', 'sid': 27}
👤ars

Leave a comment