How i can parse it?
check = request.POST.getlist('check')
print(check)
[u'["1","2"]']
send ajax JSON data to server
How i can parse it?
check = request.POST.getlist('check')
print(check)
[u'["1","2"]']
send ajax JSON data to server
It sounds like you want to decode it from JSON sent from the browser. You can do encode or decode like this:
import json
# to encode a list to json
json.dumps(yourlist)
# to decode it from json
json.loads(yourjson)
Reference: The Python Docs
In your list, you have received a string. To parse through this look-alike list, you will have to go through the individual characters. Here is an example:
list = [u'["1","2"]']
for i in range(len(list[0])):
print list[0][i]
Output:
[
"
1
"
,
"
2
"
]
You can parse through this by starting at list[0][2]
and incrementing by 4.