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

后端 未结 7 1843
感动是毒
感动是毒 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 22:04

    I would like to add one more thing that would work for people who are reading from a file.

    with open('/Users/mohammed/Desktop/working_create_order.json')as jsonfile:
                data = json.dumps(jsonfile.read())
    

    Then follow the above accepted answer i.e.

    data_json = json.loads(data)
    
    0 讨论(0)
提交回复
热议问题