Best way to encode tuples with json

后端 未结 5 1868
有刺的猬
有刺的猬 2021-02-05 00:23

In python I have a dictionary that maps tuples to a list of tuples. e.g.

{(1,2): [(2,3),(1,7)]}

I want to be able to encode this data use it with j

5条回答
  •  长情又很酷
    2021-02-05 01:01

    My recommendation would be:

    { "1": [
            { "2": [[2,3],[1,7]] }
           ]
    }
    

    It's still parsing, but depending on how you use it, it may be easier in this form.

提交回复
热议问题