Serializing list to JSON

后端 未结 3 1854
忘了有多久
忘了有多久 2020-12-02 18:31

I am sending information between client and Django server, and I would like to use JSON to this. I am sending simple information - list of strings. I tried using djang

3条回答
  •  感情败类
    2020-12-02 19:05

    You can use pure Python to do it:

    import json
    list = [1, 2, (3, 4)] # Note that the 3rd element is a tuple (3, 4)
    json.dumps(list) # '[1, 2, [3, 4]]'
    

提交回复
热议问题