Converting “true” (JSON) to Python equivalent “True”

后端 未结 7 1889
感动是毒
感动是毒 2020-12-23 21:21

The Train status API I use recently added two additional key value pairs (has_arrived, has_departed) in the JSON object, which caused my script to crash.

<
7条回答
  •  情歌与酒
    2020-12-23 21:48

    json.loads cant parse the pythons boolean type (False, True). Json wants to have small letters false, true

    my solution:

    python_json_string.replace(": True,", ": true,").replace(": False,", ": false,")

提交回复
热议问题