How can JSON data with null value be converted to a dictionary

后端 未结 2 1989
孤独总比滥情好
孤独总比滥情好 2021-01-03 17:42
{
  \"abc\": null,
  \"def\": 9
}

I have JSON data which looks like this. If not for null (without quotes as a string), I could have used ast

2条回答
  •  生来不讨喜
    2021-01-03 18:36

    One solution is to use a variable that contains None.

    import json
    null = None
    data = { "test": null }
    json.dumps(data)
    

提交回复
热议问题